Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: PIC programming  (Read 2203 times)

0 Members and 1 Guest are viewing this topic.

lilshawn

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7513
  • Last login:July 17, 2025, 05:36:09 pm
  • I break stuff...then fix it...sometimes
PIC programming
« on: January 03, 2014, 05:18:43 pm »
I'm new to this PIC thing so bear with my stupid questions. I'm familiar with it's basic operation, just nothing else.

I currently have a board with a PIC18F2455 that is already programmed that needs a serious re-design.

I would basically like to duplicate this board in function... This board has multiple inputs that it converts to RS232 terminal keystrokes to send to a computer (through a MAX232)... then takes keystrokes from the terminal (back through the MAX232) and converts them to signals to turn relays off and on etc.

Can this program that is already inserted in the PIC be dumped out so it can be dumped into another PIC?

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Today at 02:45:49 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: PIC programming
« Reply #1 on: January 03, 2014, 05:25:49 pm »
It's by no means a stupid question, but we would need a bit more info.  PICs directly drive the hardware, so the software you right to put in the PIC completely depends upon the pcb it's used on and how things are setup. 

It sounds like you don't have the source. 

The short answer is no, you can't "dump" programs back off of a pic because they are converted into pure chip logic in most cases.
The long answer is yes, you probably can, but it's kind of like taking a compiled exe and decompiling it, it'll be unreadable gibberish due to lack comments and ect. 
It entirely depends upon how complicated the code was and it sounds like it's fairly complex. 

A much better solution would be to write a new program that does the same thing.  You just need to trace your pins to figure out which ones you'll be manipulating.

I'm a beginner as well btw, so if someone else wanted to chime in that would be helpful.   

lilshawn

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7513
  • Last login:July 17, 2025, 05:36:09 pm
  • I break stuff...then fix it...sometimes
Re: PIC programming
« Reply #2 on: January 03, 2014, 06:03:20 pm »
i could probably reverse engineer it.

for instance some of the inputs simply output an a,b or c to the computer depending on which line gets grounded.

ed12

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3972
  • Last login:March 31, 2018, 03:44:39 pm
  • it is what it is..."Nobody Said It Was Easy"....
Re: PIC programming
« Reply #3 on: January 03, 2014, 07:27:21 pm »
all u need
is there pic studio
and a picstart plus
this will allow u to romove the chip and read it
plus u will get a nifty hex file to play with,then if u want u can burn others.
also u can use a header to go on the top of the chip then take jump wires to the picstart plus,both of which i have done
now if it is an spi chip :serial protocol< i will look it up
then u olny need 4 wires
spi/spc/spr/gnd
then there is a few other little things to do
but the most important right now is the pic studio
so u can see the dump

ed
Shipping something from the U.S. to Canada for repair/exchange?  Please use USPS to avoid (additional?/excessive?) shipping charges.  PM me if you have any questions.

ed12

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3972
  • Last login:March 31, 2018, 03:44:39 pm
  • it is what it is..."Nobody Said It Was Easy"....
Re: PIC programming
« Reply #4 on: January 03, 2014, 07:40:49 pm »
here u go

 Low-Power Features
    - RUN: CPU on, peripherals on
    - Idle: CPU off, peripherals on
    - Sleep: CPU off, peripherals off
    - Idle mode currents down to 5.8 ľA typical
    - Sleep mode currents down to 0.1 ľA typical
    - Timer1 Oscillator: 1.1 ľA, 32 kHz, 2V
    - Watchdog Timer: 2.1 ľA typical, 32 kHz, 2V
    - Two-Speed Oscillator Start-up
Peripheral Features
    - High current sink/source 25 mA/25 mA
    - Three external interrupts
    - Enhanced Capture/ Compare/ PWM (ECCP) module
    - Compatiable 10-bit, up to 13-channels Analog-to-Digital Converter module (A/D)
    - Capture 16-bit, max. resolution 6.25 ns
    - Compare 16-bit, max. resolution 100 ns
    - Dual analog comparators
Special Microcontroller Features
    - Priority levels for interrupts
    - 8 x 8 Single-Cycle Hardware Multiplier
    - Priority levels for interrupts
    - 100,000 erase/write cycle Enhanced FLASH program memory typical
    - 1,000,000 erase/write cycle Data EEPROM memory
    - Wide operating volatge range: 2.0V to 5.5V
    - Single supply 5V In-circuit Serial Programming via two pins  <<########
    - In-Circuit Debug (ICD) via two pins
Oscillators
    - Four Crystal modes
    - Two external Clock modes, up to 48 MHz
    - 8 user-selectable frequencies
    - Secondary oscillator using Timer1 @ 32 kHz
    - Fail-Safe Clock Monitor

<<####### now that will olny do the flash
but for the eeprom u will need the  picctarter plus and or a gq usb4000 programer,again u will still need the pic sutdio to mske sense of the dump

ed
Shipping something from the U.S. to Canada for repair/exchange?  Please use USPS to avoid (additional?/excessive?) shipping charges.  PM me if you have any questions.

ed12

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3972
  • Last login:March 31, 2018, 03:44:39 pm
  • it is what it is..."Nobody Said It Was Easy"....
Re: PIC programming
« Reply #5 on: January 03, 2014, 07:47:33 pm »
mybawd
it is mplab that u get from the web
the pcstart plus comes with pic studio as a disk
if u do not find a copy
ring me up i will find a way to get u 1

ed
Shipping something from the U.S. to Canada for repair/exchange?  Please use USPS to avoid (additional?/excessive?) shipping charges.  PM me if you have any questions.

lilshawn

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7513
  • Last login:July 17, 2025, 05:36:09 pm
  • I break stuff...then fix it...sometimes
Re: PIC programming
« Reply #6 on: January 03, 2014, 08:07:05 pm »
so if i do extract the data... can i just plunk it back into another PIC? i don't need to change the code, it's the board that is retarded.

The board is separated into 3 pieces that you have to use ribbon cables to join together, and life would be so much easier if i just amalgamated it into one board and did a run of PCB's with the connectors i need instead of having to hack everything to make it work with the board(s).

ed12

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3972
  • Last login:March 31, 2018, 03:44:39 pm
  • it is what it is..."Nobody Said It Was Easy"....
Re: PIC programming
« Reply #7 on: January 03, 2014, 08:42:39 pm »
if u yes the pic start plus yes u can
as it is olny a copy
let me chq my gq-4x and see if it dose the 8/16bit pic's
give a sec to hook it up
ya my qc-4x will pull it right up
so with that in hand u should beable to do the same thing
so then i would copy it save it as such.bin or.img or.hex
and then do what u want to the boards
knowning u can reload all the time
now i trust yours is a dip ?
if it is a flat pk u may have to do the wire intefacee i spoke about
but either way u can get there

ed
Shipping something from the U.S. to Canada for repair/exchange?  Please use USPS to avoid (additional?/excessive?) shipping charges.  PM me if you have any questions.

lilshawn

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7513
  • Last login:July 17, 2025, 05:36:09 pm
  • I break stuff...then fix it...sometimes
Re: PIC programming
« Reply #8 on: January 03, 2014, 09:07:54 pm »
yeah, it's a dip and it's socketed so pulling one is not an issue.

I'm going to have to get together a programmer of some type for it. i could probably build this for a few bucks it's just a handful of 1N4148's a cap and resistor...

http://products.foxdelta.com/art2003.htm

not sure my eeprom programer would read it. suppose it couldn't hurt to give it a try...or could...

ed12

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3972
  • Last login:March 31, 2018, 03:44:39 pm
  • it is what it is..."Nobody Said It Was Easy"....
Re: PIC programming
« Reply #9 on: January 03, 2014, 09:45:10 pm »
wont hurt the chip
it will just not want to look at it

ed
Shipping something from the U.S. to Canada for repair/exchange?  Please use USPS to avoid (additional?/excessive?) shipping charges.  PM me if you have any questions.

MonMotha

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2378
  • Last login:February 19, 2018, 05:45:54 pm
Re: PIC programming
« Reply #10 on: January 07, 2014, 12:39:29 pm »
Be aware that PIC micros (along with basically all similar microcontrollers) can be "locked" to prevent readback.  You may run into issues dumping the program that's on it.  If that happens, you can either try to unlock it by glitching it (depending on the era, this ranges from not too tough but with a ~50% chance of destroying it to essentially impossible), attempt to duplicate the functionality yourself (if it's simple, this may be the easiest route), or pay somebody to decap the chip and reset the lock bits (expensive as hell but pretty much guaranteed to work).

If you do decide that you want to re-create the software functionality from scratch, you might look into a nicer MCU. The smaller PICs are nasty, nasty things that haven't really been updated since the 80s and can be quite a pain to program for.  For small 8-bit stuff, I'm fond of AVR.  For anything non-trivial, at this point I just grab an ARM; they're cheap these days.

ed12

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3972
  • Last login:March 31, 2018, 03:44:39 pm
  • it is what it is..."Nobody Said It Was Easy"....
Re: PIC programming
« Reply #11 on: January 07, 2014, 01:06:27 pm »
MonMotha
2 very very good points
the lock bit on the pic is a easy dance if u know them
but u are 100% correct about arm and or a rasberrypi
either will do the job

ed
Shipping something from the U.S. to Canada for repair/exchange?  Please use USPS to avoid (additional?/excessive?) shipping charges.  PM me if you have any questions.

lilshawn

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7513
  • Last login:July 17, 2025, 05:36:09 pm
  • I break stuff...then fix it...sometimes
Re: PIC programming
« Reply #12 on: January 07, 2014, 01:14:27 pm »
I have an idea what needs to be done, just no idea how to do it. The last time I wrote a program it was in BASIC.  :-\

the original manufacturer of the boards has locked their software with HASP, i suspect they may have gone to the extra trouble of locking the PIC. I haven't tried it yet. I'll see what's up with that.

I'm going to make a call to the original maker of the board and see if they will pretty please give me the source to the original board PIC. They aren't supporting their stuff anymore, so it's worth a shot. If not...I guess i'm learning a new language and reverse engineering the old board. :lol

it's not terribly complicated... 4 inputs that get activated when tied to ground that get fed back to the computer through serial port (in plaintext characters)... 3 outputs that activate solenoids when ASCII codes come in from the computer (i assume latching... one code to activate and another to deactivate haven't looked into that side yet)

it's a fairly bare bones 3 chip solution (PIC to a MAX232 to convert to serial for communication and a ULN2003 on the output to control the solenoids.) All runs on 12vDC.

if there is something better and easier to use besides this PIC, I guess I would design the 1 board solution with that in mind. I don't know that i'd go so far as to replace it with ARM...I'd also stay away for the QFP and surface mounted stuff... through hole is my friend here.

Ideally I'd like to redesign the original 3 board setup to a single board, but i'd be content with reprogramming new PIC's to replace ones that have gone retarded and don't work properly anymore.

SavannahLion

  • Wiki Contributor
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5986
  • Last login:December 19, 2015, 02:28:15 am
Re: PIC programming
« Reply #13 on: January 07, 2014, 01:32:54 pm »
Just to expand a bit on Monmotha's point.

I found the PIC code structure somewhat maddening. I had a hard time "decompiling" the compiled code by hand because of the strange opcode byte boundries. I'm sure if I spent a bit more time on the matter or had the code suite ed12 offered (which by the way I'll be more than happy to take you up on) I would have had an easier time of it. At 8 bits, I tend to write in ASM and my old PC just didn't have room for the tools. PIC did have OOPIC which was similar to BASIC but is now a long dead platform. I assume PIC users nowadays code in ASM or some subset of C.

The AVR is very nice and has a huge hobbyist following similar to the old OOPIC days. In your case I would actually suggest looking at the Arduino platform. IIRC the Arduino boards have a very strong serial focus, typically by way of a serial to usb ic, but the boards can have shields added that support RS232 and other interfacing goodies. AVR has a solid ASM or C foundation while the Arduino platform is a modified C structure. There are other software platforms that bring other languages into the mix but I would suggest avoiding them. I prefer to not ever use the Arduino software for my own reasons but if time is a factor for you, it can be an option.
« Last Edit: January 07, 2014, 01:38:55 pm by SavannahLion »

ed12

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3972
  • Last login:March 31, 2018, 03:44:39 pm
  • it is what it is..."Nobody Said It Was Easy"....
Re: PIC programming
« Reply #14 on: January 07, 2014, 02:03:17 pm »
SavannahLion
once i  get my main  internet back up
i will send it dropbucket
or any ftp server of flavor
the reason u are having a bugger of a time  with the code
is as u state very correct,it is modified asm
it took me a tad to get  along with the risc because it is risc
but once onto it..well u know
and i have to agree with u nothing beats an avr..
hands down 1 of the best

ed

Shipping something from the U.S. to Canada for repair/exchange?  Please use USPS to avoid (additional?/excessive?) shipping charges.  PM me if you have any questions.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Today at 02:45:49 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: PIC programming
« Reply #15 on: January 07, 2014, 04:09:11 pm »
Just to expand a bit on Monmotha's point.

I found the PIC code structure somewhat maddening. I had a hard time "decompiling" the compiled code by hand because of the strange opcode byte boundries. I'm sure if I spent a bit more time on the matter or had the code suite ed12 offered (which by the way I'll be more than happy to take you up on) I would have had an easier time of it. At 8 bits, I tend to write in ASM and my old PC just didn't have room for the tools. PIC did have OOPIC which was similar to BASIC but is now a long dead platform. I assume PIC users nowadays code in ASM or some subset of C.

The AVR is very nice and has a huge hobbyist following similar to the old OOPIC days. In your case I would actually suggest looking at the Arduino platform. IIRC the Arduino boards have a very strong serial focus, typically by way of a serial to usb ic, but the boards can have shields added that support RS232 and other interfacing goodies. AVR has a solid ASM or C foundation while the Arduino platform is a modified C structure. There are other software platforms that bring other languages into the mix but I would suggest avoiding them. I prefer to not ever use the Arduino software for my own reasons but if time is a factor for you, it can be an option.

I tend to agree with this as well.  I mean your low end avrs can be purchased for the same price as a pic and unless you are trying to do something really fancy, most of the hardware on that pics board is probably already on your standard avr.  I would recommend a teensy... they are really cheap and it's setup with a usb bootloader that allows you to program in the arduino language as well as more traditional ones.  For simple I/O operations it's often as simple as downloading a template and configuring the pins to suit your needs. 

ed12

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3972
  • Last login:March 31, 2018, 03:44:39 pm
  • it is what it is..."Nobody Said It Was Easy"....
Re: PIC programming
« Reply #16 on: January 07, 2014, 06:24:58 pm »
btw shawn i will add this point
the pic start plus will allow u to un-lock any locked pic
it is right in the s/w
a simple click and away u go
pic start plus is usb driven now
and cost's about $125.00 plus the gov's share

ed
Shipping something from the U.S. to Canada for repair/exchange?  Please use USPS to avoid (additional?/excessive?) shipping charges.  PM me if you have any questions.