Use "Serial.write(x)" to send binary ( 8 bits) representation of your bites.
Of course you can send only 8 bites that way.
If it was me I would send the start bits first, than use next write to send the data and stop bits as last write.
Or you could convert your , assuming fixed, data into integer ( int16_t) and send it that way.
Post your first code here and the team can than help you further.
OK so here is all the information from the manufacturer of the other system I want to communicate with using my Arduino.
There are 11 bits of data in each serial string.
2 bits are start bits.
8 bits are data bits.
1 bit is a stop bit.
There are 4 transmit and 4 receive modes.
See transmit data and receive data images attached.
From the ATMEL datasheet for 328P with highlight added, answer seems to be yes.
USART0
20.1 Features
• Full Duplex Operation (Independent Serial Receive and Transmit Registers)
• Asynchronous or Synchronous Operation
• Master or Slave Clocked Synchronous Operation
• High Resolution Baud Rate Generator
• Supports Serial Frames with 5, 6, 7, 8, or 9 Data Bits and 1 or 2 Stop Bits
• Odd or Even Parity Generation and Parity Check Supported by Hardware
• Data OverRun Detection
• Framing Error Detection
• Noise Filtering Includes False Start Bit Detection and Digital Low Pass Filter
• Three Separate Interrupts on TX Complete, TX Data Register Empty and RX Complete
• Multi-processor Communication Mode
• Double Speed Asynchronous Communication Mode
ew1244:
There are 11 bits of data in each serial string.
2 bits are start bits.
8 bits are data bits.
1 bit is a stop bit.
There are 4 transmit and 4 receive modes.
See transmit data and receive data images attached.
Your images just show regular 8-bit data.
Where are you getting the idea that there must be 2 start bits? Post a link to the source of the information.
The usual Serial data format is 8N1 meaning 8 data bits, no parity and 1 stop bit. A single start bit is implied.
I wonder if you are confusing the business of sending bytes via serial with the business of interpreting the individual bits in a byte - or creating a byte whose bits reflect data from 8 different sources. It is perfectly possible to construct and deconstruct a byte.
For a bit there it looked like a no at the detail level.
20.4 Frame Formats
A serial frame is defined to be one character of data bits with synchronization bits (start and stop bits), and optionally
a parity bit for error checking. The USART accepts all 30 combinations of the following as valid frame formats:
• 1 start bit
• 5, 6, 7, 8, or 9 data bits
• no, even or odd parity bit
• 1 or 2 stop bits
A frame starts with the start bit followed by the least significant data bit. Then the next data bits, up to a total of
nine, are succeeding, ending with the most significant bit. If enabled, the parity bit is inserted after the data bits,
before the stop bits. When a complete frame is transmitted, it can be directly followed by a new frame, or the communication
line can be set to an idle (high) state. Figure 20-4 illustrates the possible combinations of the frame
formats. Bits inside brackets are optional.
But you might be able to choose 9 data bits and set the first as your second start bit, ie, cheat!
From figure 20-4
St Start bit, always low.
(n) Data bits (0 to 8).
P Parity bit. Can be odd or even.
Sp Stop bit, always high.
PS from the JPG's, those 4 modes are only within the 8 bits data.
I cut the info directly from the documentation I have. My guess is the 2 start bits determine which mode you are in. If the system (variable speed drive) is healthy you should be in mode 00 for transmit. Left pole/Right pole are your firing signals for the igbts in a h bridge inverter topology. Only if the drive faults should you change out of mode 00 to be able to reset it.
ew1244:
I cut the info directly from the documentation I have. My guess is the 2 start bits determine which mode you are in. If the system (variable speed drive) is healthy you should be in mode 00 for transmit. Left pole/Right pole are your firing signals for the igbts in a h bridge inverter topology. Only if the drive faults should you change out of mode 00 to be able to reset it.
Something to pay attention to - start / stop and other "control" bits / characters are SOMETIME of different length than the data payload.
Best solution would be to get as close as feasible to "standard" setting and let the UART do the work.
Start, stop and parity bits are what the serial port hardware are supposed to deal with, if there is a hardware serial port.
2 start bits is not standard to the AVR hardware but 9 data bits is an option so you can read and write the extra bit in your code. Your code will have to read and write int or unsigned int and use 9 bits but beyond configuring the port in setup it will not have to address the start and stop bits as the hardware will do that.
It has just crossed my mind that you may be thinking that the line at the top of each of the images in Reply #4 which says "mode 00 mode01.." are "start bits". If so, that is incorrect.
Those bits are in places 1 and 2 in the data byte and they just serve the purpose of telling the receiver how to interpret the other 5 bits.