PIC ID Number?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times

PIC ID Number?

Postby Ondra » Thu Sep 13, 2007 2:24 pm

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?.


User avatar
Matrix Staff
Posts: 14584
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4607 times
Been thanked: 4242 times

Postby Benj » Fri Sep 14, 2007 10:26 am

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


User avatar
Matrix Staff
Posts: 3104
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 89 times
Been thanked: 391 times

Postby Steve » Fri Sep 14, 2007 10:52 am

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.