FieldPoint Family

cancel
Showing results for 
Search instead for 
Did you mean: 

Using LSB as on off and remaining 7 bits as power scale

I am using the FieldPOINT FP-RLY 420 module to write values to a power supply which uses binary hi and lo's to control power.
What I need to have is the Lowest Significant Bit (Channel 0) to be the on/off control. The remaining 7 channels are the power control. So from channel 2 to 7 it counts up (or down) in a binary sequence. In other words, I need to write to the relay module binary values which are shifted one bit to the left

channel 7 channel 0
MSB LSB
x x x x x x x on/off
\----------v------------/
Binary count bits from
0 to 128

Could someone give me some help as to how I can
shift binary numbers one bit and write to the relay module so that channel 0 is on/off and the rest perform the counter job?
I appreciate any help.

Will
0 Kudos
Message 1 of 8
(5,128 Views)
If you have a numeric representation of the binary number, then multiplying and dividing by two in base-10 math left and right shifts in base-2 math.

For example, starting with binary 00001010, which is "10" in base 10. If you right shift, you get 10/2 = 5. If you left shift, you get 10*2 = 20.

Binary (Base 2) Numeric (Base 10)
00001010 10
00000101 5
00010100 20

You could fairly easily incorporate this method into the existing FP-RLY-420 example on the NI Developer Zone.

Regards,
Greg Caesar
National Instruments,
Applications Engineer
0 Kudos
Message 2 of 8
(5,128 Views)
Thanks for your reply. This answers the shifting part of the problem. However, I require to have one of the relays in the FP-RLY-420 to be an on/off relay. That is to say that when I begin my application, I turn channel zero on and a light comes on. Then the rest of the channels are used to increase the power in this light.
When I tried writing a value to channel 0 and try writing the shifted values, to the rest of the relays, there is a chatter on channel 0. This is because I'm writing both a 0 from the shifted bits and a 1 from my on/off function. I am not sure if I am explaining myself correctly. I am sending with this my VI that I've made. It is used for three different lights... but you see how I will be writing a 1 whith the on/off switch
es and a 0 with the shifted bits.
Thanks for your input in this. It is much appreciated.

Will
0 Kudos
Message 3 of 8
(5,128 Views)
Hi Will,

OK you got the shifting down.

You will have to maintian the two values (power_setting and on/off) internally in a shift register or global.
have your code write the power setting or on/off state to shift registers.
when it is time to update either, both values should be retrieved. Do the bit shifting for the power setting then add the a "1" or "0" to reflect the on/off state. The combined value is what should be written to the FP hdwr.

Note there other ways of doing this. You could write each bit seperately instead of addressing the entire port.
There may also be a mask available that will let you specify the bits taht are affected by the update.

I hope this helps,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 8
(5,128 Views)
Aaron,
I figured out what the problem was. I had one of my FPCreate Tag vi's writing to the same module, so that was causing a on-off constant switch. Anyways, your help has been excellent and much appreciated. Keep up the good work.
Will
0 Kudos
Message 7 of 8
(5,128 Views)
Ben,
I tried to do what you suggested, but unfortunately I didn't have much luck. I don't quite understand the bit about "power setting or on/off state to shift registers"
I am very new to shift registers in the sense that I understand them... so I am not sure how to create a shift register in LabVIEW. Could you please explain further.
Thanks for your reply.

Will
0 Kudos
Message 8 of 8
(5,128 Views)
Will,

The easiest solution is to create two channels that are used on the FP-RLY-420 Module. In FieldPoint Explorer, right click on the FP-RLY-420 and choose Add an Item to this Device. Name the new Item "On_Off", and set it so that it affects channel 0 only (set the channel bit mask to 0001 hex). Click on OK. Add an Item a second time, this time named "CountBits" and set it to effect channels 1 through 7 (bitmask of 00FE hex).

This gives you two different channels to write to. "On_Off" can be written to with a 0 or 1 to turn Channel 0 off or on."CountBits" can be written to with an 8 bit integer (note that the least significant bit will always be ignored). In order to compensate for the fact that the LSB will always be ignore, simply multiply your count value
by 2 (this upshifts the count by 1 LSB).

Regards,
Aaron
LabVIEW Champion, CLA, CPI
Message 5 of 8
(5,128 Views)
Aaron,
Thanks for your reply. I tried to do what you suggested. However, I still get the channel 0 relay clicking on and off, because I am writing a 1 and a zero at the same time and it doesn't kwow what it is. That is, the LSB of the eight bit integer I am writing interferes with my on/off operation.
I am not sure what to do. Any help would be appreciated.

Will
0 Kudos
Message 6 of 8
(5,128 Views)