Page 1 of 1

PIC ID Number?

Posted: Thu Sep 13, 2007 2:24 pm
by Ondra
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

Posted: Fri Sep 14, 2007 10:26 am
by Benj
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

}

Posted: Fri Sep 14, 2007 10:52 am
by Steve
There is no unique number within a PICmicro. Instead, you could hard-code an ID number into your program or store the number in the EEPROM.