Trying to get a byte (BIN) from software serial read to serial.print USB port (dec format)
// for arduino uno
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3, false); // RX, TX,
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(57600); // USB Port
while (!Serial) {;}
Serial.println("VL dim Test"); // test USB port
mySerial.begin(4800);
mySerial.println(255,BIN); // test mySerial port
}
void loop() {
byte var = 0; // set and clear 'var'
if (mySerial.available()) {
var = mySerial.read();
Serial.print(var,BIN);
}
Yes
Binary for decimal 255
that is just to test that i have a connection at that port.
trying to read from a serial line off of a Main Control Board (MCB)
that controls a sub Board.
the tx line off the MCB shows about 4v to 5v running at about 4800 baud,
(see attached photo from logic analyzer)
this bit actual should be read from MSB first to get the correct number
but for now i am just trying to get the byte to show 18 DEC or 10010 BIN on the monitor
I may need a voltage divider to reduce it to 3.3v ?
but i think the UNO should read the 5v ?
it kind of works
but it is showing strange characters on the serial monitor
not sure. i would have to do some rewiring
just to clear things up
to test some of the code, I first use a laptop with a usb to serial adapter to the pins 2 and 3
on the ardunio and the usb to my desktop
that works.
then i attach the lap top to the adrunio via USB and pin 2 (RX of the Software Serial) of the Arduino to the TX line on the MCB.
not working properly.
it is grounded.
I did try that with the code
no luck....
and
The logic analyzer decoder (UART) is inverted for the RX channel
so the start bit lines up with the 1st rise of byte
bit timing is 200us
but i am running it at 4800 baud to line up the byte
thinking i may need to load each bit into a string to print ?
I have read the posts, but I still don't understand what the problem is.
What do you want to read, what kind of signal is that, and what do you want to pass on to the the computer ? Are there Carriage Returns and Line Feeds somewhere ?
If you want to pass on the same binary data, then you should not use 'BIN', because that translates it to ASCII zeros and ones. Don't use 'DEC' either, because that translates it to a readable number in ASCII text.
With a normal Serial/UART bus, there is no problem.
This is test sketch to send 0xFF and read that with the Logic Analyzer:
// A test for the forum: https://forum.arduino.cc/t/software-serial-reading-1-byte/1221177/
// This Wokwi project: https://wokwi.com/projects/389118916901984257
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3, false); // RX, TX,
void setup()
{
// "mySerial" at pin 2 and 3.
// The RX and TX lines are idle high.
// Hopefully there are pullup resistors.
mySerial.begin(4800);
delay(5); // I would prefer 1000 ms
// For a test, send 0xFF
mySerial.print("\xFF");
}
void loop()
{
delay(10);
}
The signal is from a MCB made by vari lite
They’re pretty protective on any information that they give out
In control’s a moving head light (VL500D) PWM dimmer
The moving head runs on the DMX512 format
That controls different functions from there MCB
I did get some info on the protocol that controls there PWM module dimmer
(which they don’t make anymore) That is controlled by the MCB
They told me that it was a rx and tx line that sends 8bit’s
So I put the logic analyzer on the tx line and ran a few test’s
I came up with a basic 0 thru 255 (00000000 thru 11111111)
One start bit and a stop bit at 4800 baud
MSB first so I would have to flip the byte eventually
No carriage returns or line feeds just raw
But for starters I was hoping to just get the signal and print it out
With the arduino
Eventual y I would like to use
The byte received (0 thru 255) from the MCB to
Control the PWM on the arduino to drive
a 110vac 10amp dimmer Module Controller Board
as they did
or a relay (0 thru 127 = off, 128 thru 255 is on)
but that’s down the road....
its not 12c,spi,modbus,,,,,,
just plain old serial
There is actually 3 bytes that it send’s in sequence
The sequence is about 8ms apart
The first byte changes once in awhile (not sure for what)
The second byte seems to send the 0 thru 255 as the diming level
The third one seems to always be 255
See picture below
If there is no change from the dmx channel it only sends out the bytes
Periodically