Hello Guest it is April 18, 2024, 03:25:51 PM

Author Topic: inputs and outputs not boolean why? help!!!!  (Read 3862 times)

0 Members and 1 Guest are viewing this topic.

inputs and outputs not boolean why? help!!!!
« on: September 28, 2010, 06:08:47 PM »
I am trying to make this script:

‘ Show the user the state of the Y HOME input
If IsActive(YHOME) Then
MsgBox “Y HOME is active”
Else
MsgBox “Y HOME  is inactive”
End If

But when I debugg it and I put the mouse over YHOME to see its value shows YHOME = "5" no matter if is active or inactive always the same then acts as always false the statement.
what wolbe happening here? ???

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: inputs and outputs not boolean why? help!!!!
« Reply #1 on: September 28, 2010, 07:58:58 PM »
5 is the signal number for YHOME.
IsActive(YHOME) is the same as IsActive(5).

http://www.machsupport.com/MachCustomizeWiki/index.php?title=VB_Constants_for_Signal_Names

Here's what the manual says.
Quote
This function returns a Boolean True if the current state of the specified input signal is its
active state.  Note that in terms of actual signal level, the term “active” depends on how
the signal is defined.  If the signal is defined in Config->Ports&Pins->InputSignals as
ActiveLow, then IsActive() will return True when that signal is being driven to a logic
low.  If the signal is defined in Config->Ports&Pins->InputSignals as ActiveHigh, then
IsActive() will return True when that signal is being driven to a logic high.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: inputs and outputs not boolean why? help!!!!
« Reply #2 on: September 28, 2010, 08:47:49 PM »
As Ger21 said, what you are seeing is a side effect of the the slightly odd way the cypress basic script editor displays values.
This "editor feature" often leads me to write things differently - try this:

Code: [Select]
‘ Show the user the state of the Y HOME input
Dim B as Boolean

B = IsActive(YHOME)
If B Then
    MsgBox “Y HOME is active”
Else
    MsgBox “Y HOME  is inactive”
End If

Yeah, I know that the above is not considered "good programming style"... but you can hover the cursor over the B variable and see if it is true or false... you get to choose between style and being able able to see the variable value while debugging.

Dave
Author of the MachStdMill Extensions for Mach3
www.CalypsoVentures.com
Re: inputs and outputs not boolean why? help!!!!
« Reply #3 on: September 29, 2010, 02:16:53 PM »
thanks,
I did this as you said, now when I hover the mouse show always "false" I change the state but still never is "true"
the input in the diagnostics screen show me that the input is working  :(
Re: inputs and outputs not boolean why? help!!!!
« Reply #4 on: September 29, 2010, 10:55:35 PM »
Uh, something about the phrasing you used made me think I should ask ...

The B variable gets set to a value when the line B = IsActive(YHome) gets executed.
You are coordinating when the signal changes vs when the code is executed as part of your debugging - right?

For example:
1) use the editor to step thru the code - you will get  a value for the input from IsActive stored in B.
(we'll assume the value is true at this point) 
2) change the state of the physical input
3) restart and rerun the code again - when stepping thru it this time you should then get the opposite value for B (since it was true, it would now be false).

I mean no offense by my question; I've just found that some mach users think that scripts are constantly being executed and expect the values to change while looking at things in the editor.

Dave


Author of the MachStdMill Extensions for Mach3
www.CalypsoVentures.com