DIY Software
 
Notifications
Clear all

DIY Software

18 Posts
8 Users
0 Reactions
7,758 Views
Posts: 255
(@frankv)
Reputable Member
Joined: 17 years ago
soakes94 wrote:I have experience with programming this is just my first time at sending data to a com port. This might sound like a stupid question but when I send data to the Renard PIC I'm assuming it has to be a certain peice of data. I read the wiki and I'm still slightly confused. I copied the data I'm sending from the wiki. Im not sure if it makes sense though or if I'm just being completely stupid here.

The comms world is a bit different from the regular programming world.

You need to send commands in the language that your recipient understands. This 'language' is called a protocol, and is carefully designed to allow the right kinds of data to be sent, and to allow for error detection and recovery.

In the case of the Renard system, data is sent in groups of 8 bytes, each of which represents the brightness of one channel... 0 is off, 255 is full on.
A single comms channel may have several Renard devices listening to it, so you need some way to identify which board the data is being sent to. The protocol does this by sending the number of the device just before the data. For no particular reason, the device number is sent as a byte with the most significant bit set. Devices are numbered from 0 to 127.
To overcome a spurious character on the comms line, you precede the device byte with another byte, with value 126 (7E). Whenever a Renard device receives 7E, it throws away anything it has previously received and waits for the device number.

So if a Renard device receives a sequence 7E 7E 7E 80 10 20 30 40 50 60 70 80 it throws away the 7E, treats the 80 as the device number (device 0) and then the next 8 bytes are treated as data. So this sequence of data would turn on the 8 channels of device 0 to the 8 levels specified.


Reply
Posts: 393
Topic starter
(@soakes94)
Honorable Member
Joined: 18 years ago

I fiannly got it working 🙂 Thanks to everyone who helped out.

For anyone else that is wanting to know how I did it, I used the following lines of code when sending the data:

Dim BufferOn() As Byte = {&H7E, &H80, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF}
SerialPort1.Write(BufferOn, 0, 10)

If anyone wants a copy of the code or the program drop me a PM.

Steve


Reply
Posts: 2541
(@lightup)
Famed Member
Joined: 17 years ago

That's good news!

I'm glad you stuck with it to see your breakthrough. That's how tough problems are solved.
It's also a good educational process.


Reply
Page 4 / 4
Share: