I wrote a prog in C with the TMEX api to drive a Hobby Board IO 8ch.
I have two questions:
1) (not crucial)
when I control the logic or output state I get a sequence of 1 bit to tell the off state of relè.
Shouldn't be the opposite: 0 means relè is off?
I.e:
relè 2 is on: I get a byte of 253 -> 11111101 that reversed gives me the 0 on 2nd relè: 10111111
shouldn't be more logic having 00000010, 2nd relè is 1 that is electrified-on?
Idem for the output state. Instead the activity state I get correctly the 0: 01000000
2) (the real problem)
I got strange behaviour randomly:
Normally I get the behaviour as I described before:
es: relè 2 on:
logic state: 10111111
output state: 10111111
activity state: 01000000
Sometimes I get wrong bytes:
all 1 in the three states, or wrong activation relè.
This is very disturbing as you can't be sure which relè you electrified or which relè is active!
I think this could be interference problem in the net.
What can I do to solve this?
I put the part of code I wrote for the logic state, the output and activity are the same TMTouchByte:
That last CRCByte is not always correct.
The CRC I copied from another example but I don't understand well how it works. I tried the last CRC16 line, but doesn't get the error of the wrong CRCByte.
For example, with 2nd relè on I must get 253, instead sometimes I get 255 but the CRC16 isn't bad.
I tried also the TMTouchBit in a for cycle. Idem.
I need some advise, Thank you.
I have two questions:
1) (not crucial)
when I control the logic or output state I get a sequence of 1 bit to tell the off state of relè.
Shouldn't be the opposite: 0 means relè is off?
I.e:
relè 2 is on: I get a byte of 253 -> 11111101 that reversed gives me the 0 on 2nd relè: 10111111
shouldn't be more logic having 00000010, 2nd relè is 1 that is electrified-on?
Idem for the output state. Instead the activity state I get correctly the 0: 01000000
2) (the real problem)
I got strange behaviour randomly:
Normally I get the behaviour as I described before:
es: relè 2 on:
logic state: 10111111
output state: 10111111
activity state: 01000000
Sometimes I get wrong bytes:
all 1 in the three states, or wrong activation relè.
This is very disturbing as you can't be sure which relè you electrified or which relè is active!
I think this could be interference problem in the net.
What can I do to solve this?
I put the part of code I wrote for the logic state, the output and activity are the same TMTouchByte:
Code:
TMAccess(session_handle,state_buffer);
short rt;
unsigned char CRCByte , CRC16;
long i;
// Read PIO Registers Cmnd
TMTouchByte(session_handle,0xF0);
CRCByte = 0xF0;
CRC16 = TMCRC(1, &CRCByte, CRC16, 1);
//Issue first byte of required register (PIO Logic State)
TMTouchByte(session_handle,0x88);
CRCByte = 0x88;
CRC16 = TMCRC(1, &CRCByte, CRC16, 1);
//Issue second byte of required register
TMTouchByte(session_handle,0x00);
CRCByte = 0x00;
CRC16 = TMCRC(1, &CRCByte, CRC16, 1);
// pio logic state
CRCByte = TMTouchByte(session_handle,0xFF);
CRC16 = TMCRC(1, &CRCByte, CRC16, 1);
if ( CRC16 < 0 )
printf("ERR=%d", CRC16);
The CRC I copied from another example but I don't understand well how it works. I tried the last CRC16 line, but doesn't get the error of the wrong CRCByte.
For example, with 2nd relè on I must get 253, instead sometimes I get 255 but the CRC16 isn't bad.
I tried also the TMTouchBit in a for cycle. Idem.
I need some advise, Thank you.