Sign in

username:

password:



Not a member?

Search piclist



Search tips

Subscribe to piclist



piclist by Keywords

12F675 | 16F628 | 16F84 | 16f877 | 16F877A | 16F88 | 18F458 | ADC | AVR | Bootloader | CAN | CCS | CRC | EAGLE | EEPROM | ICD | ICSP | IDE | JDM | LED | Macros | Microchip | MPLAB | PCB-CAD | PIC10F | Pic12f675 | PIC16F84 | PIC16F84A | PIC16F877 | PIC18 | PIC18F452 | PicBasic | PICC | PICSTART | PWM | RS-485 | RS232 | SMT | SPI | UART | USART | USB | Wireless | Wisp628 | Xilinx

Ads

Discussion Groups

Discussion Groups | Piclist | 'Random' value on a PIC18F?

A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.

'Random' value on a PIC18F? - thor69uk - Jan 16 8:26:00 2006

Hello all.

New to the group so please be gentle! :-)

I am currently working on a project that allows me to add numerous
daughter boards to a master controller (PIC18F) via a CAN bus. The
problem I have is that there are several boards of the same type, but
they obviously need unique addresses in order to communicate with the
master PIC individually. I really feel that it would not be feasible
to program each board within a board type with a unique serial number
to identify them, as the situation when this problem would occur
would
only ever happen the first time a board is attached and then only
when
>= 2 of the same type are attached together at the same time.
Once each board is identified it is assigned a permanent unique
serial
number by the master controller for the bus.

So to my question…

Is there any way of allowing a `random' number function on a PIC
(that doesn't use the same `seed' value!) that I could process
with an algorithm in order to provide me with a unique address at run
time even if there are several of the same type attached?

Or…

My very simple thought to do this would be to have a `low
tolerance' RC circuit (e.g. 10-15%) on the daughter board being
attached and use an analogue input pin on the PIC to get the 10 bit
value of the pin and use this, as the probability of the constantly
changing RC circuit having the same value at the same time in
different
circuits is very, very low! Also this method would allow me to reset
the unique address if the daughter board were to be attached to a new
master controller. Would this work? I just need to get a unique number at start up so that each can be
accessed and then addressed correctly!

Am I going down a path of complication or is there a really easy way
to
do this?

Thanks in advance.

Andy




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )


Re: 'Random' value on a PIC18F? - Leon Heller - Jan 16 8:38:00 2006

----- Original Message -----
From: "thor69uk" <andrew.thornber@andr...>
To: <piclist@picl...>
Sent: Monday, January 16, 2006 12:26 PM
Subject: [piclist] 'Random' value on a PIC18F? Hello all.

New to the group so please be gentle! :-)

I am currently working on a project that allows me to add numerous
daughter boards to a master controller (PIC18F) via a CAN bus. The
problem I have is that there are several boards of the same type, but
they obviously need unique addresses in order to communicate with the
master PIC individually. I really feel that it would not be feasible
to program each board within a board type with a unique serial number
to identify them, as the situation when this problem would occur
would
only ever happen the first time a board is attached and then only
when
>= 2 of the same type are attached together at the same time.
Once each board is identified it is assigned a permanent unique
serial
number by the master controller for the bus.

So to my question.

Is there any way of allowing a `random' number function on a PIC
(that doesn't use the same `seed' value!) that I could process
with an algorithm in order to provide me with a unique address at run
time even if there are several of the same type attached?

Or.

My very simple thought to do this would be to have a `low
tolerance' RC circuit (e.g. 10-15%) on the daughter board being
attached and use an analogue input pin on the PIC to get the 10 bit
value of the pin and use this, as the probability of the constantly
changing RC circuit having the same value at the same time in
different
circuits is very, very low! Also this method would allow me to reset
the unique address if the daughter board were to be attached to a new
master controller. Would this work? I just need to get a unique number at start up so that each can be
accessed and then addressed correctly!

Am I going down a path of complication or is there a really easy way
to
do this? Dallas makes a tiny little three pin chip with a unique serial number in it.
They are quite cheap. I used to have a couple of samples, but seem to have
lost them (not difficult, they are *very* small).

Leon




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: 'Random' value on a PIC18F? - Bob Hyland, PMP - Jan 17 18:06:00 2006

Another way to do this is to have every node be responsible for
knowing its own ID. Design a new device to assumes its ID is '0'. So,
when the controller recognizes a device numbered '0', it reassigns it
a new number (just keep incrementing the highest assigned number by
1... do you need more than 255 devices on 1 bus? if so, use a 16 bit
value for 65,535 different numbers).

This is MUCH simpler than trying to develop a random number generator
and ensuring that the "random" number is not already in use.

Bob H.

--- In piclist@picl..., "Leon Heller" <leon.heller@b...> wrote:
>
> ----- Original Message -----
> Dallas makes a tiny little three pin chip with a unique serial
number in it.
> They are quite cheap. I used to have a couple of samples, but seem
to have
> lost them (not difficult, they are *very* small).
>
> Leon





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )