serout coms with Meccano™ Smart Servo
roadrunner3g.
Posts: 6
I am trying to run the servos with a BS2. They can be daisy chained up to 4 in a row. They require a 6 byte data packet [header,d1,d2,d3,d4,checksum/id]. I am having trouble with the serout command. The Checksum byte is actually comprised of two 4 bit nibbles, the upper 4 bits and the
lower 4 bits. The upper 4 bits are the actual checksum which is calculated based on the
values of Data bytes 1 through 4. The lower 4 bits contain the Module ID number which is
critical to the entire bi-directional data stream.
Each Smart Module receives the entire 6 byte data packet and then passes the exact same
data packet down to the next module. There is no shared data bus. The data going
upstream or downstream must be sent through each Smart Module.
The bits of each byte coming from the MeccaBrain™ are approximately 417us long. A “1”
bit is 417us of HIGH; a “0” bit is 417us of LOW. Each byte has a start bit (Low) and two
stop bits (High). Also, the data bits are sent in reverse order.
To be clear, each data byte looks like this
{LOW, Bit 0, Bit 1, Bit 2, Bit 3, Bit 4, Bit 5, Bit 6, Bit 7, HIGH, HIGH}
And the entire data packet would look like
{0xFF, DataByte 1, DataByte 2, DataByte 3, DataByte 4, Checksum/Module ID}
The baud rate is 2400. I can connect the BS2 to the end of the chain with the mecca brain and get the serin to read the line just fine " SERIN servo,1646, [WAIT ($FF),s1,s2,s3,s4,checksum] " , but can't make the servos work without the mecca brain. The data bytes need a "0" start bit and 2 "1" stop bits. and then there is the checksum/id byte.
lower 4 bits. The upper 4 bits are the actual checksum which is calculated based on the
values of Data bytes 1 through 4. The lower 4 bits contain the Module ID number which is
critical to the entire bi-directional data stream.
Each Smart Module receives the entire 6 byte data packet and then passes the exact same
data packet down to the next module. There is no shared data bus. The data going
upstream or downstream must be sent through each Smart Module.
The bits of each byte coming from the MeccaBrain™ are approximately 417us long. A “1”
bit is 417us of HIGH; a “0” bit is 417us of LOW. Each byte has a start bit (Low) and two
stop bits (High). Also, the data bits are sent in reverse order.
To be clear, each data byte looks like this
{LOW, Bit 0, Bit 1, Bit 2, Bit 3, Bit 4, Bit 5, Bit 6, Bit 7, HIGH, HIGH}
And the entire data packet would look like
{0xFF, DataByte 1, DataByte 2, DataByte 3, DataByte 4, Checksum/Module ID}
The baud rate is 2400. I can connect the BS2 to the end of the chain with the mecca brain and get the serin to read the line just fine " SERIN servo,1646, [WAIT ($FF),s1,s2,s3,s4,checksum] " , but can't make the servos work without the mecca brain. The data bytes need a "0" start bit and 2 "1" stop bits. and then there is the checksum/id byte.
Comments
This is not a problem when receiving, but if the servos require two stop bits they may not work.
I don't think there is a way to send two stop bits, but I haven't used basic stamps in years. Check the manual.
Bean
what is the bs2 stop bit??? high or low???
The stop bits are the same state as idle.
It might work if use a seperate SEROUT command to send each bit. As this will add a slight delay between the bytes.
You might even have to add some code between the SEROUT commands like "A = A + 0" or something to create more of a delay.
Extra stop bits are usually used to give the receiver some time to process each byte.
Bean
This was taken from the online help BASIC Stamp online help manual (which I helped create when I worked for Parallax).
data packet down to the next module. There is no shared data bus. The data going
upstream or downstream must be sent through each Smart Module.
The bits of each byte coming from the MeccaBrain™ are approximately 417us long. A “1”
bit is 417us of HIGH; a “0” bit is 417us of LOW. Each byte has a start bit (Low) and two
stop bits (High). Also, the data bits are sent in reverse order.
To be clear, each data byte looks like this
{LOW, Bit 0, Bit 1, Bit 2, Bit 3, Bit 4, Bit 5, Bit 6, Bit 7, HIGH, HIGH}
And the entire data packet would look like
{0xFF, DataByte 1, DataByte 2, DataByte 3, DataByte 4, Checksum/Module ID}
Sounds like they worked really hard to lock users in. The Propeller serial object could be modified to match that, but that may not be doable for the Basic Stamps.