View previous topic :: View next topic |
Author |
Message |
sunny Guest
|
Set unique serial number |
Posted: Wed Jan 30, 2008 10:02 am |
|
|
Dear all,
I got a request to assign an unique serial number for each of my intrument. This number would be settable in firmware at the time of manufacture and can be read later on.
I'm using PIC18F452. And I'm thinking of creating a variable that can take input value through RS232 or other port, and then store it in the EEPROM. Is it a right approach to do it?
I'm just wondering is there a more convenient way to do it?
Thanks for any suggestion! |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Wed Jan 30, 2008 10:21 am |
|
|
Do you have someone like arrow electronics burning these, or are you programming them yourself one at a time?
Look at #serialize. and #id |
|
![](templates/subSilver/images/spacer.gif) |
sunny Guest
|
|
Posted: Wed Jan 30, 2008 10:46 am |
|
|
Hi treitmey, thanks for your reply.
For now I'm just programming it by myself because it's still in prototype stage. But later on as the volume goes up, I probably will ask the board house (maybe actually their supplier) to burn it. So what's the difference between these two?
Thanks for the key words, I'll check on them. |
|
![](templates/subSilver/images/spacer.gif) |
sunny Guest
|
|
Posted: Wed Jan 30, 2008 10:54 am |
|
|
BTW, the serial number has a special format that is related to the manufacturing location (this would possible stays the same for me), and the date it's manufactured. So it's not simply an increment. |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
![](templates/subSilver/images/spacer.gif) |
sunny Guest
|
|
Posted: Wed Jan 30, 2008 12:35 pm |
|
|
Thanks again for your reply.
I'm still a bit confused. I think the benifit for using #serialization is that the serial number is stored in a designated location (for 18F452 it's 3FFFFFEh-3FFFFFh, from the datasheet you provided). But do I need to have CCS ICD to enter the serial number? I just tried it in MPLAB IDE 8.0, didn't get any prompt allowing me to enter the data. And guess I'll also need it to read it back?
So for now I'm just thinking of store it in EEPROM and use serial port to access to it. Thus later on back at the manufactory can enter the serial number without the need of IDE. Volume won't be big anyway, so should be able to do it one by one manually.
Thanks for your help! |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
![](templates/subSilver/images/spacer.gif) |
nurquhar
Joined: 05 Aug 2006 Posts: 149 Location: Redditch, UK
|
The Soloution |
Posted: Fri Feb 01, 2008 12:22 am |
|
|
I use #serialise a lot with my applications as I often have over a 100 pics hanging off a half duplex RS485 bus, thus I needed a way of addressing one at a time using a unique address. I actually program my pics with a boot loader that uses the #serialise to give each a unique address. Thus my PC can find the address of each PIC on the RS485 bus and then load an application program to each. The application can still read the serial number as it is stored at a fixed address. In my case at the top of memory where the bootloader sits.
You need to get the MachX programmer from CCS, it supports the #serialise option from within the code. What actually happes is when CCS compiles and see's a #serialise directive it puts some relavant comments at the end of the hex file. Thus regular programmmers like your ICD2 etc will just ignore them. However the MachX programmer app on the PC will read the comments and patch the program it loads from the hex with the next serial number. It will update a text file to keep track of your last serial number and you can have log file to track of when each number was programmed.
The CCS ICD unit might also work with #serialise, check with them if it does.
The other soloution which I used prior to getting my MachX was to have C prog on the PC read the hex file from CCS, look at the #serrialise comments at the end and then patch the hex file with the next serial number. You need to fix the csum at the end of each line of hex. This was a bit clunkey as I had to manualy run the prog after each burn. |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
thats what flash ram is for |
Posted: Mon Feb 04, 2008 5:33 pm |
|
|
i serialize F887's all the time - using serial port comm and un documented commands in the product's command set
during test - unique serilaization is loaded in by RS232 and set / retreived by a code snippet
thats assuming you can dedicate a bit of flash RAM to the purpose |
|
![](templates/subSilver/images/spacer.gif) |
nurquhar
Joined: 05 Aug 2006 Posts: 149 Location: Redditch, UK
|
|
Posted: Tue Feb 05, 2008 2:14 am |
|
|
Thats interesting, do you have any examples or info on how to use the "un-documented" features ? |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
undocumented command you create |
Posted: Tue Feb 05, 2008 8:17 am |
|
|
by undocumented command i mean - serial cmds you create for the device that are undocumented - - lets say you have serial cmds like RUN STOP READ etc - you also add a cmd - undocumented to the user - like SID=123456 which your program uses to WRITE that serial # or $ to flash ram - then the DOCUMENTED cmd GID? returns the 123456 by reading the same flash ram location - the SID value is set at test - via serial services and voila - you are serialized - |
|
![](templates/subSilver/images/spacer.gif) |
MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
|
Posted: Tue Feb 05, 2008 12:18 pm |
|
|
I am also using the "undocumented" special command in my command parser routines.
at firmware blow into the pic, the serial number =0
a special undocumented command, say SID=1234 would write the serial number to eeprom.
It can be read using say GID? command.
if the serial number has previously been written ( so its non-zero), then any further SID=XXX returns an error to the user.
the command GID? still works of course.
I have set up a structure for all of my data that needs to be stored in eeprom, so its a simple matter of writing the whole structure to eeprom.
hope this helps
Mike |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Feb 05, 2008 5:19 pm |
|
|
One thing I've missed in the above discussion is 'when' do you want to set the serial number? At production time or when shipping the product? For small quantities this is not a problem but when your quantities get higher this will be a time/cost factor and you likely want to program the number at production time.
Microchip uses a serial number system with external data files called Serial Quick Turn Programming (SQTPSM). Search the internet for 'SQTP' or 'SQTPSM' and you will find many programmers capable of serialization.
Some programmers capable of programming a serial number and available at MicrochipDirect:
- CCS Mach-X programmer, either by ZIF-socket or in-circuit. Works only in CCS IDE. US$199
- Microchip MPLAB PM3, either by ZIF-socket or in-circuit. Works with MPLAB or stand alone. Write serial numbers using SQTP files. US$895
- SoftLog ICP2. A production quality ICSP programmer. Works with MPLAB or stand alone. US$399
- SoftLog ICP2GANG-D. Similar to ICP2 but can program 4 chips simultaneously (expandable to 64). US$1299 |
|
![](templates/subSilver/images/spacer.gif) |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Thu Mar 20, 2008 2:20 am |
|
|
Quick & dirty method of hacking the serial number (s/n) into the PIC using ICD-U40. It does not require any code for writing the s/n (like serial command interpreter). This method uses “One Word” feature of the ICD-U40 and read_program_memory()
1. Compile your code.
2. Look at the HEX file. Find the largest program address. Description for the Intel HEX format can be found here: http://www.keil.com/support/docs/1584.htm
3. Add read_program_memory() to the code. Specify the address to read considerably larger than the max program address.
4. Compile again.
5. Download. Gotcha - this method doesn’t work with debugging.
6. Start the ICD Control Program (mine is V2.92). Click “Advanced…”. Click “One Word”
7. Specify the same address that read_program_memory() will read at run time. Specify the s/n. It’s a 16-bit number.
8. Click write _________________ Read the label, before opening a can of worms. |
|
![](templates/subSilver/images/spacer.gif) |
|