|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to read relay state?
How can I read the relay state?
Last edited by ferret_guy : 03-04-2012 at 20:44. |
|
#2
|
||||
|
||||
|
Re: How to read relay state?
the light on the relay. orange means no value, green means true and red means false
|
|
#3
|
|||||
|
|||||
|
Re: How to read relay state?
I think he's asking how to have his code know how the relay is current set, rather than his eyes.
You can see how it's done in the default project by looking at the Build Dashboard Data.vi. That retrieves the values of the Relays and sends it off to be displayed by the default Dashboard. |
|
#4
|
||||
|
||||
|
Re: How to read relay state?
Quote:
When the light is orange both are connected to GND. When the light is green M+ is connected to +12 and M- is connected to GND. When the light is red M+ is connected to GND and M- is connected to +12. When the light is off M+ and M- are connected to +12 The PWM cable can be confusing also as it is not really PWM. It is connected to a relay output on the Digital Sidecar. The black wire is tied to the negative. The red and white wires are connected to + 5 when the cRIO wants to activate a contact. I cannot remember which controls which. Here is a link to the manual: http://www.robotmarketplace.com/prod...sersManual.pdf (If you are right, Mark, Maybe my explanation will help someone) Last edited by kstl99 : 03-04-2012 at 22:19. |
|
#5
|
||||
|
||||
|
Re: How to read relay state?
in code, if you run debug mode(running robot main) to your robot, than you can probe your relay state by clicking on the wire while the code is running.
|
|
#6
|
|||
|
|||
|
Re: How to read relay state?
so I looked in the dashboard build code and there are two sections under digital IO Relay forward and relay reverse witch output an unsigned integer 0 to 255 but I cannot find out how this is correlated to the relay states
|
|
#7
|
|||||
|
|||||
|
Re: How to read relay state?
The short answer is, each Relay has a Forward side as well as a Reverse side.
We have 8 Relays per Digital Sidecar. So we can represent the state of all Relays by using just two 8-bit integers where each bit indicates if the Relay position is on or off (1 or 0). Instead of thinking of it as a number 0-255, think of each bit position being on or off. The first bit of the Forward integer represents Relay 1's forward setting (on=1, off=0). The 8th bit represents Relay 8. The same with the Reverse bit values. There are two distinct parts to a Spike relay that kstl99 referred to in his description earlier. Essentially, a Spike is really two relays in one. So, because there are two parts, each Spike has 4 states where each of the two parts is either on or off. These are the enumerated choices you get in the code for a Relay:
Those rows of green and red lights are the bit values in your integers. One way to use these numbers is to run the integer through a "Number to Boolean Array" function and an "Array to Cluster" followed by an Unbundle (from the right-click cluster menu). An alternative is to use the array index functions to pick out the values you want. I've attached an example. Beware, the array starts with zero, so the Relay 1 is zero and Relay 8 is seven. The "Number to Boolean Array" function can be found in the block diagram palette under Programming->Boolean The "Array to Cluster" function is under Programming->Array Last edited by Mark McLeod : 04-04-2012 at 20:41. |
|
#8
|
|||
|
|||
|
Re: How to read relay state?
thanks!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|