Arduino Forum

Community => Exhibition / Gallery => Topic started by: Soranne on Feb 20, 2012, 07:12 pm

Title: Arduino as a Pic Programmer!
Post by: Soranne on Feb 20, 2012, 07:12 pm
Hi everyone!

Here is my first version of my PIC programmer : program your PIC from USB! Cheap and easy!
Feel free to do what you want with this project, modify it, upgrade it publish it,... but just tell me what you've done so that I can share it with everybody ;)

It works with PIC 16F628 but should work with most pic16F; if you can try at home leave a message so that I can list the working PICs here!

Here is the circuit you need to make :
(http://img11.hostingpics.net/pics/210379schma.png)
You can change the resistor value between 330 and more.
Always RESET Arduino before putting 12V (I don't know if we need to, but that's just a safe practice)


And here is the code :
Code: [Select]
/*
PIC programmer using Arduino
This program is distibuted "AS IS", I offer no garantee.
By Ronan Gaillard
*/
#define  CLOCK  9
#define  DATA   8
#define  VPP1   6
#define  VPP2   5
#define  VPP3   4
#define  PGM    10 //HIGH/LOW voltage select mode
#define  MCLR   11 //LOW voltage only

void setup() {                
 
 pinMode(CLOCK, OUTPUT);    
 pinMode(VPP1, OUTPUT);
 pinMode(VPP2, OUTPUT);
 pinMode(VPP3, OUTPUT);
 pinMode(DATA, OUTPUT);  
 pinMode(PGM, OUTPUT);  

 Serial.begin(9600);
 Serial.println("Started");
//Serial.println("Send s to start (please put Vpp first)");
while(true)
{
  if (Serial.available() > 0)
  {
   if(Serial.read()=='s')//HIGH VOLTAGE MODE
  {
   //VIN should be around 12V max. is 13.5V
 
 
  digitalWrite(VPP1, HIGH);
  digitalWrite(VPP2, HIGH);
  digitalWrite(VPP3, HIGH);

    Serial.print("D");
   break;
  }
  else//low voltage mode
  {
 digitalWrite(PGM, LOW);
 digitalWrite(VPP1, LOW);
  digitalWrite(VPP2, LOW);
   digitalWrite(MCLR, LOW);
  digitalWrite(VPP3, LOW);
  delayMicroseconds(20);
  digitalWrite(VPP1, HIGH);
  digitalWrite(VPP2, HIGH);
  digitalWrite(VPP3, HIGH);
  delayMicroseconds(3);
  digitalWrite(PGM, HIGH);
    delayMicroseconds(3);
    digitalWrite(MCLR, HIGH);
    Serial.print("D");
   break;
  }
  }
 
}
}

void loop() {
 
 char command = '\0';
 
  if (Serial.available() > 0) {
   
    command = Serial.read();
   
    switch(command)
    {
    case 'b' :
     BulkEraseProgramMemory();
     
      Serial.print('D');
    break;
   
    case 'E' :
      EndOfProgramming();
      Serial.print('D');
      break;
   
    case 'r' :    
      char valeur[16];
      ReadDataFromProgramMemory(valeur);
      for(int i=0; i<14;i++)
      {
       Serial.print(valeur[i]);
      }
      //Serial.print("D");
    break;
   
    case 'l' :
      char WritingValue[14];
      for(int i=0;i<14;i++)
      {
       while(Serial.available() == 0)
       {
       }        
       WritingValue[i] = Serial.read();
      }
     
     
      LoadDataCommandForProgramMemory(WritingValue);
     
     
      Serial.print('D');
      break;
     
    case 'w' :
      BeginProgrammingOnlyCycle();
      Serial.print('D');
    break;  
   
    case 'W' :
      BeginEraseProgrammingCycle();
      Serial.print('D');
    break;  
   
    case 'i' :
      IncrementAddress();
      Serial.print('D');
      break;
     
    case 'c' :
      char ConfigValue[14];
      for(int i=0;i<14;i++)
      {
       while(Serial.available() == 0)
       {
       }        
       ConfigValue[i] = Serial.read();
      }
      LoadConfiguration(ConfigValue);
      BeginProgrammingOnlyCycle();
     
      Serial.print('D');
      break;
     
    case 'R' :
     
   
      digitalWrite(VPP1, LOW);
      digitalWrite(VPP2, LOW);
      digitalWrite(VPP3, LOW);
     
      delay(3);
     
      digitalWrite(VPP1, HIGH);
      digitalWrite(VPP2, HIGH);
      digitalWrite(VPP3, HIGH);
     
      Serial.print("D");
     
    break;
     
   
    }
  }
 

}
void WriteBit(char nb)
{
 digitalWrite(CLOCK, HIGH);
 if(nb!='0')
 {
   digitalWrite(DATA,HIGH);
 }
 delayMicroseconds(3);
 digitalWrite(CLOCK, LOW);
 delayMicroseconds(3);
 
   digitalWrite(DATA,LOW);
 
}

byte ReadBit()
{
 byte valeur = 0;
 
 digitalWrite(CLOCK, HIGH);
 delayMicroseconds(3);
 if(digitalRead(DATA)==HIGH)
 {
  valeur = '1';
 }
 else
 {
   valeur = '0';
 }
 digitalWrite(CLOCK, LOW);
 delayMicroseconds(3);
 
 return valeur;
}
void ReadDataFromProgramMemory(char valeur[])
{
 digitalWrite(DATA,LOW);
 
 //Command
 
 WriteBit('0');
 WriteBit('0');
 WriteBit('1');
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 
 pinMode(DATA, INPUT);
 delayMicroseconds(3);
 
 //DATA
 ReadBit();
 for(int i =13;i>=0;i--)
 {
   valeur[i] = ReadBit();
 }
 ReadBit();
 
 
 
 pinMode(DATA, OUTPUT);
 
 
}

void LoadDataCommandForProgramMemory(char valeur[])
{
 digitalWrite(DATA,LOW);
 
 //Command
 
 WriteBit('0');
 WriteBit('1');
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 
 
 delayMicroseconds(3);
 
 //DATA
 WriteBit('0');//always 0
 for(int i =13;i>=0;i--)
 {
   WriteBit(valeur[i]);
 }
 WriteBit('0');//always 0 (stop bit)
 
 delayMicroseconds(3);
 
 
 

 
 
}
void BeginProgrammingOnlyCycle()
{
 digitalWrite(DATA,LOW);
 
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 WriteBit('1');
 WriteBit('1');
 WriteBit('0');
 
 
 delayMicroseconds(3);
 

 

 
 delay(20);
}

void BeginEraseProgrammingCycle()
{
 digitalWrite(DATA,LOW);
 
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 WriteBit('1');
 WriteBit('0');
 WriteBit('0');
 
 
 delayMicroseconds(3);
 

 

 
 delay(20);
}

void BulkEraseProgramMemory()
{
 digitalWrite(DATA,LOW);
 
 WriteBit('1');
 WriteBit('0');
 WriteBit('0');
 WriteBit('1');
 WriteBit('0');
 WriteBit('0');
 
 
 delayMicroseconds(3);
 
 
 
 delayMicroseconds(3);
 
 delay(20);
}

void FullEraseProgramMemory()
{
 char Erase [] = {'1','1','1','1','1','1','1','1','1','1','1','1','1','1'};
 LoadDataCommandForProgramMemory(Erase);
 BulkEraseProgramMemory();
 BeginProgrammingOnlyCycle();
}

void IncrementAddress()
{
 digitalWrite(DATA,LOW);
 
 WriteBit('0');
 WriteBit('1');
 WriteBit('1');
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 
 
 delayMicroseconds(3);
}

void LoadDataCommandForDataMemory(char valeur[])
{
 digitalWrite(DATA,LOW);
 
 //Command
 
 WriteBit('1');
 WriteBit('1');
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 
 
 delayMicroseconds(3);
 
 //DATA
 WriteBit('0');//always 0
 for(int i =13;i>=0;i--)
 {
   WriteBit(valeur[i]);
 }
 WriteBit('0');//always 0 (stop bit)
 
 delayMicroseconds(3);
 
 
 

 
 
}
void LoadConfiguration(char valeur[])
{
 digitalWrite(DATA,LOW);
 
 //Command
 
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 WriteBit('0');
 
 
 delayMicroseconds(3);
 
 //DATA
 WriteBit('0');//always 0
 for(int i =13;i>=0;i--)
 {
   WriteBit(valeur[i]);
 }
 WriteBit('0');//always 0 (stop bit)
 
 delayMicroseconds(3);
 
 
 

 
 
}

void EndOfProgramming()
{
 digitalWrite(DATA,LOW);
 
 //Command
 
 WriteBit('1');
 WriteBit('1');
 WriteBit('1');
 WriteBit('0');
 WriteBit('1');
 WriteBit('0');
 
 delayMicroseconds(3);
}








To program use your COM port, here are the commands :
Code: [Select]
Just after RESET send s to start with HVP (High Voltage Programming) or S to start with Low Voltage Programming

wXXXXXXXXXXXXXX : writes word to location pointed by PC (program counter)
i : increases PC
r : read current location
e : erase full program memory
R : resets the PIC (PC to 0)
Every command returns character D if success


To Do :
- This only reads and writes to program memory on PIC, improve it to access DATA memory(=EEPROM)
- Support more PICs

Supported PICs : (Your PIC is not listed here? Don't hesitate to post a comment here so that I can add it!)
Most 16F pics should be supported


Don't hesitate to tell me if it works with other PICs.


Latest updates :
03/03/2012 : updated C# prog + arduino code
24/02/2012 : uploaded new Software that writes to Prog memory and loads the Configuration Word, and uploaded the Arduino Firmware, which supports LVP (Low Voltage Programming) by sending 'S' just after RESET.
22/02/2012 : updated the C# code : you can now burn HEX file to PIC! (only program memory supported, not EEPROM and Config word)
21/02/2012 : added the reset command, and started to program a C# program to send HEX to PIC



Here is a 18f programmer : https://sites.google.com/site/thehighspark/arduino-pic18f Special thanks to kirill578!

Enjoy,
Soranne
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 21, 2012, 07:14 pm
Here is the start of the C# prog used to control the Arduino PIC programmer, not finished at all, just a start ;) (updated on 24/02/2012)


You need to :
- reset Arduino before starting the prog/reading/writing
- don't forget the 12V
- .NET Run Time 4.0 (should already be on your PC if you use Windows)


See end of post for download

As this is just a prototype I encourage you to check your PIC memory with your normal programmer.

Title: Re: Arduino as a Pic Programmer!
Post by: Techone on Feb 22, 2012, 01:13 am
That is an interesting project. I will figured out this project, doing experiments amd try it.

Thank Soranne. Merci  <-- In english in this section.   :D
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 22, 2012, 05:37 am
HI Sorraine such a nice project i have different types of pic's a few putting up with me lying around without a JDM programmer usage as my desktop us ruined it cant be used on laptop so i can check with those pic's.

i just wanted that can you provide intallable exe file of your c# programme which is used to programme pic's (i dnt have visual c# IDE installed and configured)
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 22, 2012, 09:07 am
Quote
That is an interesting project. I will figured out this project, doing experiments amd try it.

Thank Soranne. Merci  <-- In english in this section.   


Thank you for your comment :) Merci!

Quote
HI Sorraine such a nice project i have different types of pic's a few putting up with me lying around without a JDM programmer usage as my desktop us ruined it cant be used on laptop so i can check with those pic's.

i just wanted that can you provide intallable exe file of your c# programme which is used to programme pic's (i dnt have visual c# IDE installed and configured)


Hi NI$HANT,
Thank you for your comment too!
For the moment I'm not providing the *.exe because the program doesn't burn the hex file yet :s . As soon as I have improve the program I will post the *.exe here ;)
This afternoon (it's now 09:06 in France ;) ) I will certainly have a good c# program running so I will post the exe here !
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 22, 2012, 09:09 am
Thanks a lot SOrraine, Im waiting for it impatiently.do not want to struggle for with parallel programmers and serial programmers any more.

Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 22, 2012, 06:51 pm
Hi,
I uploaded the C# prog to the second post. See indication on second post ;)
Enjoy!
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 22, 2012, 07:16 pm
I'm the First to Download it, but im sure not the last!  :D
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 23, 2012, 08:44 am
Thanks! :) I just noticed there may be a problem : the software might writeMSB (Most Significant Byte) first whereas it should write LSB (Least Significant Byte) first. I'll check this afternoon!
Have a nice day!

EDIT : i fixed everything, I also added configuration word support. But I have an internet problem so I can't upload my code and .exe yet :s
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 23, 2012, 07:43 pm
@ Soranne, Hi thanks for prompt update, I'm eagerly waiting for the latest .exe file and code, please prompt ASAP.
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 24, 2012, 05:20 pm
Working on LVP (Low Volatage Mode = no need for 12V) and release the code in less than one hour!

PS : just received my 16F876A, so I'm gonna try! ;)

EDIT : ARRRRRHHHHH having problemes with LVP :s Doesn't work, actually 16F876 don't work like 16F628, that's a bit more complicated than ithought. Anybody who want to help is welcome!
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 24, 2012, 06:20 pm
I think Sorrance giving external 12v to programme should not be that much of a headache for us Arduino Dude's  :D for us the fact that arduino is being able to route the binary into the chip is enough and also these Stubborn PIC's would not that easily let one access them in low voltage mode ,However some would but not all.
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 24, 2012, 06:42 pm
Yeah that was just a test, too much trouble yet, I'll try it later.
I just posted the software and new Arduino code up there :)
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 24, 2012, 07:25 pm
I just downloaded the latest code from the second post and want to know that whether you want to give me some instructions on using it.
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 25, 2012, 11:38 am
Just follow what the program says and put your hex file in C:/mem.hex
And before starting the prog reset the Arduino, it should work ;)
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 25, 2012, 01:15 pm
and.... if i want to extract out the program from PIC then  i will find the HEX in C:\

??
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 25, 2012, 01:51 pm
No not implemented yet :s

But don't worry I'm working on that ;)

By the way, I'm working on the GUI, so that everything gets simpler, here is how it should look :

(http://nsa22.casimages.com/img/2012/02/25/120225055648819886.png)
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 26, 2012, 03:06 am
That is further very nice, but how long will it take?
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 26, 2012, 04:52 pm
I may finish it in less than one hour if everything goes well.

As I'm a student, and that the holidays fiinishe today I will only be able to post updates on week-end from now on.
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 26, 2012, 04:56 pm
That is fine Sorrane, i look forward to the finalization.
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 26, 2012, 05:23 pm
Here is the reading part working :

(http://nsa21.casimages.com/img/2012/02/26/120226053422536013.png)
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 26, 2012, 06:12 pm
Uploaded the prog to second post, but it's still buggy, and doesn't support config word yet
Title: Re: Arduino as a Pic Programmer!
Post by: peteec on Feb 26, 2012, 06:23 pm
Really good work Soranne,I'm very intrested in this too,Will give it a try on later on the pic's i have and report back,Great Work Thanks  XD
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 26, 2012, 07:20 pm
Thanks a lot sorrane for the finalization of that software, also which all pic's can we read? and do we have to select the respective PIC from the dropdown then in that case which one PIC you have covered?

also, Does the Arduino programme remains the same?

Also, Do we get the HEX file read from the PIC under C:/ drive?
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 27, 2012, 08:59 am
WAS TRYING OUT WITH 2 12F683'S
I got the following (see attachement) prompt from it and while it shows all zeros in bits everywhere, so where im wrong.

The way i made connections to the 12F683 are in the attachment named conn..

EDIT:
the app is hanging when i click on read
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 27, 2012, 06:42 pm
The program doen't work with  12F683 yet, I have to add support :s

But reading should work normally, if the program freezes that may be because you didn't reset the Arduino before starting the prog...
Tell me if it still doesn't work.
But remeber this is a beta version, so still a bit buggy... :s

For the read function : it only reads the 50 first words. And your connection with pic seems to be fine.
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 27, 2012, 07:24 pm
Its fine if it doesnt work with 12F683 but i really appreciate your efforts -->  :)

Ya it still doesn't work , i'm utilizing the program as follows

1) Reset the arduino (offcourse after the sketch is loaded on arduino)
2) Then start the Windows programme that you made.
3) change the Port to the one which im connecting the arduino with.
4) Then i change the name of the PIC to 12F683

then click on read, but nothing works the windows opens at some try's but it all shows 0000000000 , first i thought it may be happening bcz the PIC may be locked on its bits to protect the software , then i used another 12F683 that i bought afresh and after writing to it many times, whenver i read and if it worked sometimes then it shows all 000000000 in bits
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 28, 2012, 08:05 am
That is weird, maybe the 12F683 has a really different protocol I need to checkout the datasheet.
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 29, 2012, 09:09 am
Any Update?
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Feb 29, 2012, 06:53 pm
As I'm a student, and that I have a lot of homework during the week I can only work on this project on week-ends.
Sorry about that.
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Feb 29, 2012, 07:00 pm
Ok that is fine.
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Mar 03, 2012, 06:36 pm
Updated C# code and arduino code, should work with many pics (doesn't support config word yet...).

Don't forget to reset PIC before reading/writing. If the prog says "access to COMX denied", just close and re-open the prog.
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Mar 04, 2012, 06:22 am
Thanks! i will get back to you with the results.
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Mar 04, 2012, 09:47 am
Ok! :)
I'm not sure about writing, but reading should work fine ;)
Title: Re: Arduino as a Pic Programmer!
Post by: Nishant_Sood on Mar 04, 2012, 02:35 pm
How can the Read software be saved?
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Mar 04, 2012, 03:13 pm
Not implemented yet but you can still copy/paste the text from the output window...
Does reading work for you?
Title: Re: Arduino as a Pic Programmer!
Post by: zorglub76 on Mar 13, 2012, 07:40 am
Hey, just wanted to give you two thumbs up for this project!
I've spent some time looking for a way to program pic through arduino and only found some (pretty arrogant) guys saying that it's not possible.. I wanted to make a PicKit2 clone, but needed something to burn hex to 16f2550, and it seems that your solution is exactly what I was looking for. It's unfortunate that I won't have time to try it soon, but keep up the good work!
Title: Re: Arduino as a Pic Programmer!
Post by: sharath12 on Mar 24, 2012, 09:27 pm
Hey Sorraine,
This is a nice project. Does this work for PIC24 (PIC24FJ256GA110) ?
Title: Re: Arduino as a Pic Programmer!
Post by: watchinofoye on Apr 02, 2012, 02:30 pm
Hi, Soranne !

As I said on the french topic of your project - http://arduino.cc/forum/index.php/topic,93067.0.html - I'm trying to reproduce the same kind of project with a PIC18F2550.
When i'll finish it, i'll share it on this topic, attached with a report. I expect that will help everybody else to adapt this project to their favorite microcontroller.

Cordially,

Watchi~
Title: Re: Arduino as a Pic Programmer!
Post by: tazzo on Apr 02, 2012, 09:01 pm
Very interesting project!
Title: Re: Arduino as a Pic Programmer!
Post by: MikeOToole on Apr 02, 2012, 10:36 pm
Ditto... must keep an eye on this as my Pic programmer uses serial and my new PC doesn't... ;)
Keep it up Soranne, nice project...
Mike
Title: Re: Arduino as a Pic Programmer!
Post by: ijager on Apr 06, 2012, 01:53 pm
Hi, watchinofoye

I was also trying to build an Arduino PIC programmer for the PIC18F2550. So far without much success.

Here is my code:

Code: [Select]
/*
* Trying to build an arduino pic programmer for the PIC18F2550
* Programming specifications: http://ww1.microchip.com/downloads/en/DeviceDoc/39622L.pdf
* Author: Ingmar Jager
*/

//Pin layout
int pgc = 9;  // program clock
int pgd = 8;  // program data
int pgm = 10;  // program mode
int MCLR = 11; //Master Clear Reset / Vpp

void setup()
{
 Serial.begin(9600);
 
 pinMode(pgc, OUTPUT);
 pinMode(pgd, OUTPUT);
 pinMode(pgm, OUTPUT);
 pinMode(MCLR, OUTPUT);
 delay(500);
 
 enterProgramming();
 delay(500);
 tableRead(0x3F, 0xFF, 0xFF);
 delay(500);
 tableRead(0x3F, 0xFF, 0xFF);
 exitingProgramming();
}

/*
* @param: three bytes which form the tablepointer address
*/
void setTablePTR(int addr_upper_byte,int addr_half_byte,int addr_lower_byte)
{
 
Serial.print("Set TablePTR to: 0x");
Serial.print(addr_upper_byte, HEX);
Serial.print(addr_half_byte, HEX);
Serial.println(addr_lower_byte, HEX);

writeBits(4, 0x0); // 4 bit command
writeBits(16, 0x0E00 + addr_upper_byte); // 16 bit data payload: load address
writeBits(4, 0x0);
writeBits(16, 0x6EF8);  // set TBLPTR_U to addr_upper_byte

writeBits(4, 0x0);
writeBits(16, 0x0E00 + addr_half_byte);
writeBits(4, 0x0);
writeBits(16, 0x6EF7); //TBLPTR_H

writeBits(4, 0x0);
writeBits(16, 0x0E00 + addr_lower_byte);
writeBits(4, 0x0);
writeBits(16, 0x6EF6); //TBLPTR_L
 
}
/*
* Read byte from the given address
*/
void tableRead(int high_byte, int mid_byte, int low_byte)
{
 
 setTablePTR(high_byte,mid_byte,low_byte);
 
 writeBits(4, 0x8); //1000 = Read and no increment
 writeBits(8, 0x00);
 pinMode(pgd, INPUT);
 delayMicroseconds(5); //P6
 
 byte data = 0;
 //actual read
 Serial.print("Read bits from LSB to MSB: ");
 for (int i = 0; i < 8; i++)
 {
   digitalWrite(pgc, HIGH);
   delayMicroseconds(3); //P14
   
   if (digitalRead(pgd)==HIGH)
   {
     Serial.print("1");
     data += (1 << i);
   }
   else
   {
     Serial.print("0");
   }
     
   digitalWrite(pgc, LOW);
       delayMicroseconds(3);
 }  
 
 delayMicroseconds(5); //P5A
 pinMode(pgd, OUTPUT);
 Serial.println();
 Serial.print("Reading result: ");
 Serial.println(data);
}
 
/* Write LSB to MSB
* @param n = number of bits to write
* @param value = value to write in n bits
*/
void writeBits(int n, int value)
{
 digitalWrite(pgc, HIGH);
 for (int i = 0; i < n; i++) {
    if( (boolean) ((value >> i) & 1))
       digitalWrite(pgd,HIGH);
 }  
 delayMicroseconds(3);
 digitalWrite(pgc, LOW);
 delayMicroseconds(3);
 digitalWrite(pgd,LOW);
 delayMicroseconds(5); //P5A
}

/*
* Entering low voltage programming signals
*/
void enterProgramming()
{
  digitalWrite(pgc, LOW);
  digitalWrite(pgd, LOW);
  digitalWrite(pgm, LOW);
  digitalWrite(MCLR, LOW);
 
  delayMicroseconds(20);
 
  digitalWrite(pgm, HIGH);
  delayMicroseconds(3);//P15
  digitalWrite(MCLR, HIGH);
  delayMicroseconds(3);//P12
  Serial.println("Entered Low Voltage Programming");
}

/*
* Exiting low voltage programming signals
*/
void exitingProgramming()
{
  digitalWrite(pgc, LOW);
  digitalWrite(pgd, LOW);
  delayMicroseconds(1); //P16
  digitalWrite(MCLR, LOW);
  delayMicroseconds(1); //P18
  digitalWrite(pgm, LOW);
  Serial.println("Exiting Low Voltage Programming");
}


void loop()
{

}



I'm trying to read the deviceID on address 0x3FFFFF. According to the programming specifications the DEVID1 = 010x xxxx and DEVID2 = 0x12.
When I run my program, this is the output:
Code: [Select]
Entered Low Voltage Programming
Set TablePTR to: 0x3FFFFF
Read bits from LSB to MSB: 00000000
Reading result: 0
Set TablePTR to: 0x3FFFFF
Read bits from LSB to MSB: 00011111
Reading result: 248
Exiting Low Voltage Programming


So the first time I try to read the ID register it returns 0. However the second time the result is 00011111 (248). If I read it a third time it is 0 again. So I'm not quite sure what is happening here.

Have you got some better results?

Title: Re: Arduino as a Pic Programmer!
Post by: Legot on Apr 30, 2012, 03:37 am
I have been having issues with the GUI version.
When I Burn a hex to the pic, it seems to work (tx light on usb adapter flashes, etc) and the program says "Finished!" after a short time.
However, when I hit "Read from PIC" all lines (0-49) say 00000000000000

I'm using a PIC16F628A
Title: Re: Arduino as a Pic Programmer!
Post by: sirbow2 on May 03, 2012, 12:51 am
ive been looking for something like this for a long time; great work!
Title: Re: Arduino as a Pic Programmer!
Post by: kirill578 on May 03, 2012, 03:38 pm
I wrote a similar sketch for the PIC18F2550 ( a slight modification can adopt it to almost all pic18F2/4 family). the sketch and the instruction can be found over here:

https://sites.google.com/site/thehighspark/arduino-pic18f
Title: Re: Arduino as a Pic Programmer!
Post by: aepiscis on May 03, 2012, 05:41 pm
Hi soranne,

sorry, I don´t speak english very good

I know how to get 12V from USB port, There are two ways:

1.-With a coil and a zenner

2.- With capacitors, Diodes and a zenner

the first option are more easy but it is more difficult to get the coil.

I will post here how to make

reggards.
Title: Re: Arduino as a Pic Programmer!
Post by: watchinofoye on May 04, 2012, 11:37 pm
Quote
I wrote a similar sketch for the PIC18F2550 ( a slight modification can adopt it to almost all pic18F2/4 family). the sketch and the instruction can be found over here:

https://sites.google.com/site/thehighspark/arduino-pic18f
Damn ! Project already done !
Well, I'll still try to do it, at least to understand the ICSP method and achieve implementation by myself.
But, even so I am disgusted ! >.< I was caught up again ! Just my luck !
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on May 06, 2012, 06:35 pm
Hey all! sorry for answering so late but I have been busy with a lot of homework :s
I have to say I am not sure I will be able to work again on this project because it involves a lot of time (coding a programming method for nearly every pic!).
What Is suggest is that someone who is really motivated gathers all the programming methods for each pic to make one nice prog.

Hope I can help again!
Title: Re: Arduino as a Pic Programmer!
Post by: mahk on May 18, 2012, 10:38 pm
hi soranne where i can find your program c# to load pic?
also what is latest state your project?
Title: Re: Arduino as a Pic Programmer!
Post by: mahk on May 18, 2012, 10:41 pm
and soranne your project page (https://sites.google.com/site/thehighspark/arduino-pic18f )  is broken
is there any alternatif link??
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on May 19, 2012, 05:44 pm
Dear mahk,

I am sorry this page is not my project.
Title: Re: Arduino as a Pic Programmer!
Post by: mahk on May 19, 2012, 06:09 pm
hey soranne can you give me  alink for this project(circuit,program)
i need this project for my thesis in school
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on May 19, 2012, 06:34 pm
All the infromation I have is on the first page
Title: Re: Arduino as a Pic Programmer!
Post by: tekaikko on May 20, 2012, 01:50 pm
Hi!

A good project!
In case interested, I've created an Arduino programmer for PIC32 series. The details are found at http://code.google.com/p/ardupic32/ (http://code.google.com/p/ardupic32/).

Cheers!
Title: Re: Arduino as a Pic Programmer!
Post by: diogo0880 on May 22, 2012, 04:43 pm
Hi Soranne!

I think you save me! Please tell me that I can program a PIC18F452 or a PIC16F88 (with I prefer) using your project.
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on May 23, 2012, 07:47 am

Hi Soranne!

I think you save me! Please tell me that I can program a PIC18F452 or a PIC16F88 (with I prefer) using your project.


Hey!
Of course you can! But depending on the protocol they use you may need to adapt a bit the code.
Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on May 23, 2012, 02:36 pm
But personnaly I would prefer the beaglebone to the raspberry pi ;)
The beaglebone looks more like an arduino (you can easily access the inputs/outputs and and shields)  and is more powerful than a raspberry pi, even if it's a bit more expensive.
Title: Re: Arduino as a Pic Programmer!
Post by: itchan on May 24, 2012, 09:03 am
How do i connect the pic16f684? I checked the datasheet and it doesnt have pins labeled as RB4 RB6 AND RB7? :(
Title: Re: Arduino as a Pic Programmer!
Post by: spunky on Jul 28, 2012, 09:01 am
Hi all,

Mine is PIC16F887

Im trying to program it using your programmer (the .exe application) and have few question.

How to send the command "s" ? i want to program using low voltage.

and how to wire it? here's what I got from my PIC datasheet.(attached)
(http://img72.imageshack.us/img72/2601/capturetmu.jpg)

hoping someone can give me circuit suggesstion. thanks  :)
Title: Re: Arduino as a Pic Programmer!
Post by: BlueGuzz on Jul 28, 2012, 03:55 pm
Hint: If you look at post #2 and there is no link to the *.exe file, you have to create a forum account and log in. An advise in post #2 would be nice.
Title: Re: Arduino as a Pic Programmer!
Post by: faisalfasi on Aug 04, 2012, 09:33 pm
wow seems like I got answer of my unasked question,going to use it in one of my own project:)
thanks for your help!!!
Title: Re: Arduino as a Pic Programmer!
Post by: Thiagofelipe on Sep 06, 2012, 02:05 am
Soranne could you enable the program and a manual to use it because I'm not getting alone!
Title: Re: Arduino as a Pic Programmer!
Post by: timmerk on Oct 14, 2012, 01:24 am
Hi Soranne,

Any chance you could post the C# code for the application?

Thanks!
Title: Re: Arduino as a Pic Programmer!
Post by: flyboy_____ on Oct 18, 2012, 03:46 pm
Soranne I have been following this project and now I want to program one PIC12F683.
Can it now be programed with your current version of this project?
Title: Re: Arduino as a Pic Programmer!
Post by: flyboy_____ on Oct 20, 2012, 11:40 am

Soranne I have been following this project and now I want to program one PIC12F683.
Can it now be programed with your current version of this project?


Anyone posting here?
Title: Re: Arduino as a Pic Programmer!
Post by: djsaw1994 on Oct 24, 2012, 11:20 pm
Hello, men the programmer works 100%¡¡¡ congratulations, but
the programmer only work with BASIC code, i´m try with
C code copiled with PIC C and dont work.

you see the picture.

sorry for bad inglish, i´m spanish.

Title: Re: Arduino as a Pic Programmer!
Post by: Soranne on Oct 31, 2012, 09:25 pm

Hello, men the programmer works 100%¡¡¡ congratulations, but
the programmer only work with BASIC code, i´m try with
C code copiled with PIC C and dont work.

you see the picture.

sorry for bad inglish, i´m spanish.




Hey,

That is a weird error, comes from the hex file itself, you should try to convert it to INTEL HEX format if you can.


To all others : I receive a lot of questions, unfortunately I don't have time to support that project anymore, because of my studies. I am really sorry about that. I also have seen that the C# code has disapeared, i will repost it as soon as possible.

Best regards.
Title: Re: Arduino as a Pic Programmer!
Post by: ionuionu on Nov 04, 2012, 01:11 pm
please can you make a step by step for me? i don't understand how to use the second code(for COM)
Title: Re: Arduino as a Pic Programmer!
Post by: woku on Dec 08, 2012, 10:40 am
Hi Soranne, would you please upload again the circuit diagram? The one mentioned in your page at http://img11.hostingpics.net/pics/210379schma.png is no longer available.  Thank you.
Title: Re: Arduino as a Pic Programmer!
Post by: simu on Jan 13, 2013, 02:09 pm
Hi

I'm trying to download the Program from the second post. But something seems to be wrong with the file. I'm not able to open it. Is it really a zip Archive?

Thanks for helping me out.
Title: Re: Arduino as a Pic Programmer!
Post by: ondeugd on Jan 15, 2013, 06:10 pm
The zip in the post is corrupted.
Is there anyone with the original working version willing to upload it somewhere?

cheers


P.s. I did manage to repair the downloaded zip from the second post using some 'diskinternals zip repair' tool (I can start the ArduinoPic.exe, can't test if it is working correctly at the moment). Not sure how to attach anything to this post, but some zip-repair tool might help you too.
Title: Re: Arduino as a Pic Programmer!
Post by: simu on Jan 17, 2013, 11:59 am
Great, Thanks!

p.s.: when you type a reply, just below the textfield there is a little text "Additional Options...". You have to click on it, then you see where you can upload ("Attach") files.

EDIT: Just did it myself. Here's the recovered zip-file.
Title: Re: Arduino as a Pic Programmer!
Post by: sjforion on Apr 17, 2013, 01:54 am
Doesn't look like that zip file is working either. Really interested in trying this out. Does anyone know where I can get that C# program?
Title: Re: Arduino as a Pic Programmer!
Post by: JacobChrist on May 03, 2013, 06:01 pm
Have you tried this code on a chipKIT board?

Jacob
Title: Re: Arduino as a Pic Programmer!
Post by: Combo on May 19, 2013, 12:29 am
I'd like to use my Arduino to program a PM25LD010C-SCE chip.  It's actually an 8-pin bios flash chip for a computer graphics card.  I'm wondering if this will allow me to program that chip, and if not, whether it could be done by modifying your code/schematic?
Title: Re: Arduino as a Pic Programmer!
Post by: Tabasko on Jun 10, 2013, 10:54 pm
Does some one has a Tutorial for this , im a bit confused
thx
Title: Re: Arduino as a Pic Programmer!
Post by: m9898 on Jun 18, 2013, 09:35 pm
Does this also work with PIC16F505-I/P?
Title: Re: Arduino as a Pic Programmer!
Post by: ValterFukuoka on Jun 29, 2013, 04:14 am
Hi, cool project, very nice.
I want to try it.
The reason is that I am developing a project that can benefit from it. My project uses a PIC bootloader, and this Arduino-PIC Programmer seems to be a nice combination to my project.
[My questions]
It seems that I can use the 16F628A or 16F88 or 16F886/887 for tests, right?
And, is there a list of already tested MCUs?
The GUI Uploader Application is also available?
Is there any current website with information about it?

(https://dl.dropboxusercontent.com/u/29669031/physoft/uBlackBox_general_MICROMINI.jpg)
*The photo in this post is the micro-black-box (as in aviation) prototype, which is part of the Moleculine Project.

Below URL to software I am using:
My Project is called Moleculine Project:
https://sites.google.com/site/psmoleculine/ (https://sites.google.com/site/psmoleculine/)

MicroBlackBox Prototype:
https://sites.google.com/site/microbbox/ (https://sites.google.com/site/microbbox/)

Also, there is another PIC Programmer using RaspberryPI here (which I am also using):
http://holdenc.altervista.org/rpp/ (http://holdenc.altervista.org/rpp/)

The PIC bootloader I am using help developing (modifying):
http://www.microchip.com/forums/m614768.aspx (http://www.microchip.com/forums/m614768.aspx)

The Python GUI software uploader I am using and help developing (modifying):
http://tinybldlin.sourceforge.net/ (http://tinybldlin.sourceforge.net/)

Thanks all,
Regards,
Valter Fukuoka
Nagoya City, Japan
Title: Re: Arduino as a Pic Programmer!
Post by: elfrock on Aug 04, 2013, 09:38 pm
Try to use Arduinopic program without success..
when I write my .hex to pic it pass ok and Arduinopic shows "Finished"
but when I try to read data from pic I get ONLY 49 data words with complete different data.
Anyone had this problem?
What It could be?
Title: Re: Arduino as a Pic Programmer!
Post by: hrickards on Oct 08, 2013, 12:33 am
Hi guys,

I've been trying to program a 627A over the last week or so. I initially tried Soranne's code, but I didn't have much success and I wanted to write a PC-side programming script compatible with linux anyway. In the end, I wrote a new sketch based on Sorrane's, and managed to get the programming working (I think the issue might be due to slightly different timings needed for the -A version).

Anyway, everything's detailed more on my post (http://forum.arduino.cc/index.php?topic=192118.0) and GitHub (https://github.com/hrickards/pic_programmer) page. Hopefully it's of use to someone!
Title: Re: Arduino as a Pic Programmer!
Post by: Ghostbird on Dec 06, 2013, 04:16 pm
I cannot get it to work. What am I doing wrong?

I upload the code into the Arduino
I connect the PIC16F88 to the Arduino
I connect the USB
I connect the 12V
I hit the reset on the Arduino
I sent the reset command 'r' to the Arduino
I sent the HVP command 's' to the Arduino
I execute:
Code: [Select]
for i in `cat gateway2.hex`; do echo w$i >> /dev/ttyACM0; sleep 0.01s; echo i >> /dev/ttyACM0; sleep 0.01s; done
NOTE: For every line in the hex code it sends 'w' + <line data> to the Arduino. Then it sleeps for 1ms. Then it sends 'i' to the Arduino to increment the PC. Then it sleeps for 1ms.
Every command is acknowledged by the Arduino with 'D'. Still it seems to not be programmed. The 'r' command always returns 00000000. It seems the PC is never incremented.
Title: Re: Arduino as a Pic Programmer!
Post by: pamirdeb on Aug 05, 2014, 09:45 pm
I know this a very old forum but putting question expecting some reply. I tried the method mentioned to program PIC18F2525 but no success. Could any one advise how a PIC18F2525 chip can be programmed using arduino?

Sorry for my English.
Title: Re: Arduino as a Pic Programmer!
Post by: JnrGuerreiro on Aug 17, 2014, 01:43 am
Hello, I was confused by this post.
I rode the circuit as the image, and I sent the BlinkLed program for the pic, after completed , the ArduinoPic.exe show me Success message but, didn't work.

Would someone help with this.
I Used arduino Mega 2560 and PIC 16f628A.
Would someone draw the schematic in the Fritzing Program to be more clear to understand.

Thanks advance.


Title: Re: Arduino as a Pic Programmer!
Post by: john-baroo on May 11, 2015, 07:50 pm
heeeeeeeeeeeeelp
arduinopic give me error : error im hex file : missing colon
 :o  :o  :o  :o  :'(  :'(  :'(  :'(  :'(
Title: Re: Arduino as a Pic Programmer!
Post by: pavankumark on Aug 03, 2015, 01:49 pm
hi,
      your project is very interesting. but help me where i can include the code which is to be written into the pic.
Title: Re: Arduino as a Pic Programmer!
Post by: Motanache on Sep 13, 2015, 07:55 am
I am very interested in this project.

I want to program a PIC using a tablet with ARM processor

1. Arduino
Arduino Microchip programmer:
http://forum.arduino.cc/index.php?topic=92929.0

Arduino droid:
https://play.google.com/store/apps/details?id=name.antonsmirnov.android.arduinodroid2&referrer=utm_source%3Dgoogle%26utm_medium%3Dorganic%26utm_term%3Darduino+google+play&pcampaignid=APPU_1_zQX1Vd-4PMWiU62Nt_gE

Arduino commander
From Google Play - Free

I do not understand what kind of Arduino is used here as programator.

The discussion is old, in 2012, I not know if anyone responding there.
I have PIC12F675 with 12Vpp
and PIC30F2020 with 5Vpp
Title: Re: Arduino as a Pic Programmer!
Post by: alampr87 on Oct 06, 2015, 03:19 pm
Hello guys,

this project looks very interesting!
But I've one questions: As I'm using OSX and Linux, is it possible to get this program as a bash script? Otherwise I may write a script on my own if you can provide source code or process description!

Best regards!
Title: Re: Arduino as a Pic Programmer!
Post by: avhohlov on Oct 10, 2015, 02:59 am
Why need to short pins 4, 5 and 6 in initial circuit?

When pin states are changed one pin in HIGH state may be connected to other pin in LOW state during short time.
I think in that time pins current exceed limit.

I test ardpicprog (http://rweather.github.io/ardpicprog/). Only one pin used to supply VDD. Moreover I connect PIC.VDD, DATA and CLK to Arduino by 220 OHm resistors and it seems work (I use PIC16F630).
Title: Re: Arduino as a Pic Programmer!
Post by: gelfling6 on Oct 12, 2015, 09:46 pm
Kinda coming in on the trailing end myself..  I just recovered an old 'Telezapper' (Privacy Technologies Inc.  Supposed to have warded-off telemarketers from your analog land-line, by generating a tone that told the telemarketers that your phone line was a Commercial Business line, and thus Illegal to keep on their bulk-dialling list.) And it has... a 12C508A sitting there.   I just briefly scanned through the thread, and a few quick follow-up questions (and please point me to the answers?) Can the ArduinoPIC programmer READ the content of the PIC's EEPROM, and how difficult is it to wire-up out of off-the-shelf parts for the complete (read/write) programmer hardware?
Title: Re: Arduino as a Pic Programmer!
Post by: Paul__B on Dec 26, 2015, 06:44 am
and soranne your project page (https://sites.google.com/site/thehighspark/arduino-pic18f )  is broken
is there any alternative link??
It is there now, anyway.
Title: Re: Arduino as a Pic Programmer!
Post by: venkat46c on Feb 17, 2016, 05:12 pm
anyone please help me i work out this circuit with arduino last two day nothing is getting work
please feed some ideas
i use the pic16f628a mc
and ardunio uno r3
by using breadboard nothing i ill get
if i use to program by using programmer.exe if its read but nothing is stored pls helpme
Title: Re: Arduino as a Pic Programmer!
Post by: xechehot on Mar 20, 2016, 07:40 pm
Try to use Arduinopic program without success..
when I write my .hex to pic it pass ok and Arduinopic shows "Finished"
but when I try to read data from pic I get ONLY 49 data words with complete different data.
Anyone had this problem?
What It could be?
Hello! I have the same problem with reading of PIC16F833 using this ArduinoPic programmer (only 49 lines readed). But when I am trying to write some .hex it starts and show "please wait" and nothing else. It is about 10 minutes of programming. Is it normal? How long time is needed? I have aborted the process and try again.

Does someone have the source code of C# application?
Title: Re: Arduino as a Pic Programmer!
Post by: ThothLoki on Feb 22, 2017, 05:42 pm
Do you know if this will this work for a PIC16F819-I/F?
Title: Re: Arduino as a Pic Programmer!
Post by: neorpheus on Mar 16, 2017, 06:46 pm
Any idea if this would work with the PIC18F2321? I came into quite a few of these through my work and would like to see about using them in place of comparable atmel chips due to their greater speeds. I have quite a few of these so I'm not afraid to sacrifice several of them to testing if need be.
Title: Re: Arduino as a Pic Programmer!
Post by: Jordanelektronika on Apr 11, 2018, 08:32 am
I also experience the problem "error in hex file:missing colon"!

The reading seems to be find, I use the PIC in c sharp program from the second post. Any ideas how to solve it are appreciated!
Title: Re: Arduino as a Pic Programmer!
Post by: xt1058 on May 09, 2018, 11:17 pm
Can I use it in Linux?
Title: Re: Arduino as a Pic Programmer!
Post by: e-San on Mar 28, 2019, 11:52 am
I know that this topic is very old, but I have PIC16F818 and I need to check if it works (eventually download flash). I can not find instruction on how to connect those pins. Can anyone help me?

Also, this seems to be fine, can anyone judge if it's ok?:

I cannot get it to work. What am I doing wrong?

I upload the code into the Arduino
I connect the PIC16F88 to the Arduino
I connect the USB
I connect the 12V
I hit the reset on the Arduino
I sent the reset command 'r' to the Arduino
I sent the HVP command 's' to the Arduino
I execute:
Code: [Select]
for i in `cat gateway2.hex`; do echo w$i >> /dev/ttyACM0; sleep 0.01s; echo i >> /dev/ttyACM0; sleep 0.01s; done
NOTE: For every line in the hex code it sends 'w' + <line data> to the Arduino. Then it sleeps for 1ms. Then it sends 'i' to the Arduino to increment the PC. Then it sleeps for 1ms.
Every command is acknowledged by the Arduino with 'D'. Still it seems to not be programmed. The 'r' command always returns 00000000. It seems the PC is never incremented.
As a side note - this chip can be programmed with low voltage.
Title: Re: Arduino as a Pic Programmer!
Post by: pdavis68 on Sep 02, 2019, 08:01 pm
I realize this is a really old topic, but I want to build this and the original schematic is no longer available at its old link, but I think this is the original:

(https://i.ibb.co/dKCD3GQ/arduinopic.png)

Thought it would be nice to drop it here in case anyone else wanted to build this.