PDA

View Full Version : Remembering Previous State



niwa3836
January 10th, 2009, 05:32 AM
Hi,

Some quick guidance please if possible.
I have an RS232 to power box when I send RS232 it changes relay contacts. The thing is that you send the state for the entire relay bank in 1 go and therefore if I turn on relay 1 by send 0x01, its turns on relay 1, when I send 0x08 it turns on relay 4 but turns off relay 1.

Whats the best way of ensuring when I turn on relay 4 that relay 1 doesnt go off. Must be something around states?

Many
Thanks
Nigel

Rob H
January 10th, 2009, 12:24 PM
You'll need to save the current state yourself using a bit of Lua code I guess.

niwa3836
January 11th, 2009, 12:36 AM
Hi Ron, thanks for your reply.

So the basic (copied) lua script that i am using to create this as a serial port needs to be modified and store state somewhere (memory, girder or disk?)

Does anyone know any lua's that exist that do this today? This way i could try and reverse engineer the concept.

For the purposes of searching forums, if anyone wants to or gets stuck interfacing with cisco hardware / software i can certainly help. I have already written a number of interfaces and certain can help pointing in the right direction.

Rob H
January 11th, 2009, 04:38 AM
For now I'd suggest simply maintaining the state in a Lua variable - probably as a field of the serial device.

Once that's working you can consider the persistence mechanism - e.g. take a look in the help for the ptable library.

VicVonDoom
January 11th, 2009, 12:32 PM
what relay card is it?

i had the same problem with an Audon.co.uk Som1 4 way relay card...

I'll see if i can find the gml/serial stuff that rob wrote a while back if it helps?
You might be able to adjust it slightly to suit if needed

VicVonDoom
January 11th, 2009, 12:40 PM
whoops - just read its a power switch box, see if this helps or not...

goes in girder5>plugins>serial

niwa3836
January 15th, 2009, 05:53 AM
Sorry this was a wrong post, full post below

niwa3836
January 15th, 2009, 05:56 AM
Hi, thanks for the reply.

So the last post LUA looks really hopefully, however I am missing something. Presuming I change the script, where would I change the code to actually send the initial chars. I also need to send the checksum, to do this I need to add up the chars in an 8 bit field. Once finished I am sure this will help others. Please have a look at the board on ebay, £35 quid is reasonable (although you need to build a box).


In girder then what do I use to trigger? I presume somehow I call SwitchRelay = function(self, relay, state) type fucntion?

For the purposes of future posts / readers. The unit is a FR88 RS232 Relay Board 8-In/8-Out Robot VB LabVIEW.

As of 15/01/09 search on ebay for item 110327828710

Byte Bit Data Description State
0 0-7 xxxxxxxx Start of receive data string 00111100 = 3C
1 0-7 00000000 String length Default = 6 bytes
2 0-7 00000000 Spare By default = 0
3 0 0000xxx1 Relay Q0.0 On/Off Control 1=Relay On, 0=Relay Off
1 0000xx1x Relay Q0.1 On/Off Control 1=Relay On, 0=Relay Off
2 0000x1xx Relay Q0.2 On/Off Control 1=Relay On, 0=Relay Off
3 00001xxx Relay Q0.3 On/Off Control 1=Relay On, 0=Relay Off
4 0000xxxx Spare
5 0000xxxx Spare
6 0000xxxx Spare
7 0000xxxx Spare
4 0 0000xxx1 Darlington Q1.0 On/Off Control 1=Output low, 0=Output high
1 0000xx1x Darlington Q1.1 On/Off Control 1=Output low, 0=Output high
2 0000x1xx Darlington Q1.2 On/Off Control 1=Output low, 0=Output high
3 00001xxx Darlington Q1.3 On/Off Control 1=Output low, 0=Output high
4 0000xxxx Spare
5 0000xxxx Spare
6 0000xxxx Spare
7 0000xxxx Spare
5 0-7 xxxxxxxx Checksum 1 byte 0-255