PIC ID Number?

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

Moderators: Benj, Mods

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

PIC ID Number?

Post 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

User avatar
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:

Post 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

}

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

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

Post Reply