/* http://www.utrainia.com/65-arduinocmri-and-rs485
/* Arduino CMRI and RS485
*/
#include <Auto485.h>
#include <CMRI.h>
#define CMRI_ADDR 0
#define DE_PIN 2
#define LED_PIN 13
Auto485 bus(DE_PIN); // Arduino pin 2 -> MAX485 DE and RE pins
CMRI cmri(CMRI_ADDR, 24, 48, bus); // defaults to a SMINI with address 0. SMINI = 24 inputs, 48 outputs
void setup() {
pinMode(LED_PIN, OUTPUT);
bus.begin(19200);
}
void loop() {
// 1: main processing node of cmri library
cmri.process();
// 2: update output. Reads bit 0 of T packet and sets the LED to this
digitalWrite(LED_PIN, cmri.get_bit(0));
// 3: update input. Flips a bit back and forth every second
cmri.set_bit(0, (millis() / 1000) % 2 == 0);
}
Hi KlausST,Hi,
You say:
* on breadboard it is working
* on PCB it's not working
But you
* neither show what you did on breadboard,
* nor what you did on PCB.
So how can we find out what's the difference?
Klaus
The DRC is set up per manufacturer requirements. The ground plane is a polygon on the back, connected where needed, no missing connections.Hi,
It seems to be an EAGLE layout.
Did you run the DRC? Some signals seem to be "more than close" to each other.
There are a lot of issues makinkg validation difficult: Non standard symbols, no pin numbering.
The trace routing is from from good .. but could be improved witin a couple of minutes.
GND is cut into pieces (as far as I can imagine) and thus can´t act as a GND plane.
What happend with C9/C7 and C8/C6? (Why in connected parallel and why 180° rotated?)
please use EAGLE commands:
* dis none top bot via pad tpla
* rat
-> then upload the screenshot as .PNG (area a bit wider than in your .PDF)
Klaus
Added:
Sadly in your photos we can´t see which wire goes to which pin (But this is important if you want us to give advice). They don´t seem to be wired equally.
This device acts as a slave.Basic information missing. What's the peer in your test? How are the communication roles?
Error description suggests that your device has slave role, is receiving some RX data, but not recognizing it. Besides specific circumstances, e.g. comparision with breadboard behaviour, there's a basic way to analyze the received data, check if it arrives correctly at the microcontroller receive routine and why it's not recgnized as valid request.
1. The RX signal can be checked for valid serial frame characteristics. You can identify the baud rate and even decode messages in the oscilloscope waveform. Ideally your oscilloscope can decode UART protocols and display the data bytes. RX line should have high idle state, but we don't know where the captured data stream actually starts. There might a problem of reversed polarity or missing RS485 pull-up/-down resistors.
2. Use Arduino debugging methods to check how the incoming data is seen by the UART.
quite unusualRX is idle low.
Why?Hi,
Sadly I was not clear enough with
* the EAGLE command
* the .PNG
* the photos
Klaus
--- Updated ---
quite unusual
Klaus
You didn´t perform the EAGLE commands as givenWhy?
Sorry to read your comments:Hi,
You didn´t perform the EAGLE commands as given
You didn´t upload the PNG, but a PDF
You don´t show photos where we can verify the wiring.
*****
On UART signals Rx as well as Tx are idle HIGH.
I see that the MAX458 has a grey zone between -200mV and +200mV for (A-B).
So this might cause the "not idle HIGH".
Better use some 700 Ohms biasing resistors to pull A with to +5V and B to GND.
Also when RE=1 then RO = HIGH-Z, thus the state is undefined. Better use a pull up to get known and valid levels
Klaus
--> command:I do not understand what you mean by "Eagle comments"
Every OS lets you do a screenshot.that is what I got from Eagle
Yes, I´ve read this very often in the forum .....I confirm that my wiring is checked
Hi Brian,I would consider it a miracle if it worked at all with such long wiring and no decoupling capacitor, you were lucky!
Can you post a picture of the scope trace with RX, TX and the direction control signals on screen at the same time so we can see the relative timing between them.
Brian.
Is there a way to correct this in software? The controller I use (AtMega328 in "pro mini" version) does not have a UART chip, TX and RX are directly read by the controller.I'm glad it is resolved. A and B are equal but opposite voltage levels so if swapped, the traces will still look correct but the UARTs at each end will not be able to frame the bytes correctly.
Brian.
/* http://www.utrainia.com/65-arduinocmri-and-rs485
/* Arduino CMRI and RS485
*/
#include <Auto485.h>
#include <CMRI.h>
#define CMRI_ADDR 0
#define DE_PIN 2
#define LED_PIN 13
Auto485 bus(DE_PIN); // Arduino pin 2 -> MAX485 DE and RE pins
CMRI cmri(CMRI_ADDR, 24, 48, bus); // defaults to a SMINI with address 0. SMINI = 24 inputs, 48 outputs
void setup() {
pinMode(LED_PIN, OUTPUT);
bus.begin(19200);
}
void loop() {
// 1: main processing node of cmri library
cmri.process();
// 2: update output. Reads bit 0 of T packet and sets the LED to this
digitalWrite(LED_PIN, cmri.get_bit(0));
// 3: update input. Flips a bit back and forth every second
cmri.set_bit(0, (millis() / 1000) % 2 == 0);
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?