Thanks for all that replied.
Well, I tried to solve the issue by software with no success. The code below is a stripped down
version of code posted elsewhere as an example on how to get data from the EM406-A. I´ve
changed it to read all data in a buffer first, to avoid timing issues, and changed the logic of
detecting IDLE and START bits. Got no valid data for all combinations.
#define bit4800Delay 188
#define halfBit4800Delay 94
byte rx = 7;
// Control logic for IDLE, START BIT, etc.
byte IDLE;
byte START;
// EM406 serial content is stored here
#define MAX_SIZE 1100
byte output[ MAX_SIZE ];
void setup() {
pinMode( rx, INPUT );
Serial.begin( 9600 );
// Init buffer with all 1s
for( int i = 0; i < MAX_SIZE; i++ ) {
output[i] = 255;
}
}
char SWread() {
byte val = 0;
while (digitalRead(rx) == IDLE );
//wait for start bit
if( digitalRead(rx) == START ) {
delayMicroseconds( halfBit4800Delay );
for (int offset = 0; offset < 8; offset++) {
delayMicroseconds( bit4800Delay );
val |= digitalRead( rx ) << offset;
}
//wait for stop bit + extra
delayMicroseconds(bit4800Delay);
delayMicroseconds(bit4800Delay);
return val;
} else {
return 'A';
}
}
void loop()
{
// Inverted logic for IDLE and START bits. Tried
// also with IDLE=HIGH and START=LOW
IDLE = LOW;
START = HIGH;
for( int i = 0; i < MAX_SIZE; i++ ) {
output[i] = SWread();
}
Serial.println( "Direct" );
for( int i = 0; i < MAX_SIZE; i++ ) {
Serial.print( output[i], BYTE );
}
Serial.println( "Inverse" );
for( int i = 0; i < MAX_SIZE; i++ ) {
byte inv = ~output[i];
Serial.print( inv, BYTE );
}
while( 1 ) {
}
}
With or without the inversion guess the way to go is first convert the signal levels to
0~5V just to be sure.
In the meantime it would be great to have any report on the use of this module
with the Uno.