Good day all. It seems I'm spending so much time on this computer days just blend into each other. Anyway here's my question. Do PICs have a built in ID Number. I want to create a network of PIC's each with it's own ID. Does anyone know what is the best way to go about this?.
Ondra
PIC ID Number?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Hello Ondra
Most PICmicro devices have a built in ID number but this generally relates to the device family and product name. It would be easier to create some kind of bus to connect the devices together. This bus could be I2C, RS232, CAN, LIN etc. Once you have decided upon your bus you can assign the addresses manually.
I created a RS232 network for my Masters project which had a network of 3 PICmicro devices talking to each other.
All you have to do is listen for incoming messages. If a message comes in then check to see if it is your address. If not then go back to waiting. If it is your address then you know that the next byte sent will be a command or data. You can use the most significant bit of the byte to assign a address or not. This way you will not have to transmit the device address every other transfer.
Here is the psudo code
Listen for byte
if there is a byte present
Yes {
Is the byte an address (is the MSb a 1)
Yes - Is it my address Yes - set as the current device / No - Disable as the current device
No - Am I the current device Yes - Process data / No - Ignore Data
}
Most PICmicro devices have a built in ID number but this generally relates to the device family and product name. It would be easier to create some kind of bus to connect the devices together. This bus could be I2C, RS232, CAN, LIN etc. Once you have decided upon your bus you can assign the addresses manually.
I created a RS232 network for my Masters project which had a network of 3 PICmicro devices talking to each other.
All you have to do is listen for incoming messages. If a message comes in then check to see if it is your address. If not then go back to waiting. If it is your address then you know that the next byte sent will be a command or data. You can use the most significant bit of the byte to assign a address or not. This way you will not have to transmit the device address every other transfer.
Here is the psudo code
Listen for byte
if there is a byte present
Yes {
Is the byte an address (is the MSb a 1)
Yes - Is it my address Yes - set as the current device / No - Disable as the current device
No - Am I the current device Yes - Process data / No - Ignore Data
}
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel