Dangerous Prototypes

Dangerous Prototypes => Bus Pirate Support => Pirate PIC programmer => Topic started by: ian on December 10, 2011, 09:38:11 am

Title: PicProgrammer v2 for BusPirate v4 Development
Post by: ian on December 10, 2011, 09:38:11 am
For the SMPS - the goal would be 3.3volts to ~18volts output, maybe clamped at 24volts? The idea is an adjustable output for different PIC/AVR/EEPROM programming voltages. Also handy if you need an inconvenient bias voltage for some reason :)
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 10, 2011, 09:50:07 am
Can't we do with 5V USB input? Also what do you think about current requirements?
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: rsdio on December 10, 2011, 10:30:47 am
[quote author="tayken"]Can't we do with 5V USB input? Also what do you think about current requirements?[/quote]
USB delivers at least 4.01 V, guaranteed, and that voltage should be enough to generate any voltage using an inductor and switching boost regulator. Problem is that the power would be limited to well under 2.5 W, but I guess that's understood.

I wonder whether a DAC output could be mixed in the feedback loop of a boost regulator to allow PIC control of boost output voltage. There should be an example circuit somewhere...
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: ian on December 10, 2011, 10:44:27 am
I assumed 3.3v so we could get the widest range of values, including 3.3-5v. Indeed, it is only intended to be a programming voltage (pic uses 1uA or something small of 9-13v), bias voltage, or reference, not a serious current source.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: rsdio on December 10, 2011, 10:55:16 am
[quote author="ian"]it is only intended to be a programming voltage (pic uses 1uA or something small of 9-13v), bias voltage, or reference, not a serious current source.[/quote]
I assume you mean that the programmed part is not a serious current load, or current sink, right?

I don't think that a 9 V to 13 V "reference" would be appropriate (overkill?), but a regulator or any other voltage should be adequate.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 10, 2011, 11:12:16 am
[quote author="rsdio"][quote author="tayken"]Can't we do with 5V USB input? Also what do you think about current requirements?[/quote]
USB delivers at least 4.01 V, guaranteed, and that voltage should be enough to generate any voltage using an inductor and switching boost regulator. Problem is that the power would be limited to well under 2.5 W, but I guess that's understood.

I wonder whether a DAC output could be mixed in the feedback loop of a boost regulator to allow PIC control of boost output voltage. There should be an example circuit somewhere...[/quote]
OK, so lets assume input voltage between 4-5V, am I right? Lets say current draw will be 1uA at 13V, so output power is 13uW, not that much. But lets design the converter for a higher current output. just in case.

Dave has some new videos on EEVBlog, there he is using (at least will use, just watched part 1) PWM from a uC as reference, feedback. That was one of my ideas for DP SMPS, I'll watch the remaining ones and probably it is possible with some buffer 4 filter.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: ian on December 10, 2011, 11:36:06 am
Yes, the PIC just needs the 13-9v to go into programming mode, there is no real actual load.

There is a demo somewhere where I used the BP PWM and ADC to do a PWM up to 80 or 90 volts :) I also ahve an instruct able with spreadsheets for calculating all the parts of a simple uC driven booster.
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 10, 2011, 12:02:19 pm
I couldn't find your demo but found this (http://http://dangerousprototypes.com/2009/11/22/bus-pirate-high-voltage-power-supply/).

Also a link (http://http://www.instructables.com/id/High-Voltage-Switch-Mode-Power-Supply-SMPSBoost/?ALLSTEPS) to Instructables.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: JTR on December 10, 2011, 08:46:59 pm
[quote author="ian"]The bottom line, I think an eventual update of the Bus Pirate will need a fet and coil for a SMPS, and a way to switch it :)[/quote]

Yes, this is really what the adapter board needs, variable, firmware controlled Vpp. For anyone writing software/firmware this feature is something that I recommend strongly that you plan for, even if it is not currently used. It will save a lot of work later on.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: ian on December 11, 2011, 11:37:02 am
Here's the SMPS demo:
http://dangerousprototypes.com/2009/12/ ... y-6-parts/ (http://dangerousprototypes.com/2009/12/04/bus-pirate-boost-converter-with-only-6-parts/)
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 11, 2011, 12:16:44 pm
Thanks Ian, I guess we can put a series resistor on ADC pin to get some sort of feedback and run a closed loop for adjusting the duty cycle accordingly. It can be a very good add on for v4 or we can include this on v5. :D

I'll work out some part values and get them when I'm in Akihabara next time.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: rsdio on December 12, 2011, 07:34:48 am
[quote author="tayken"]Thanks Ian, I guess we can put a series resistor on ADC pin to get some sort of feedback and run a closed loop for adjusting the duty cycle accordingly.[/quote]
Do you plan on voltages over 5 V ?  If so, then you'll need a voltage divider instead of just a series resistor.  Also, if VUSB drops below 5 V then the ADC input won't accept 5 V, so you might still need the divider.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: ian on December 12, 2011, 08:30:41 am
Ithink somewhere in SVN this is a firmware that does the feedback. I have no idea where though :)
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: Sjaak on December 12, 2011, 09:38:12 am
[quote author="rsdio"][quote author="tayken"]Thanks Ian, I guess we can put a series resistor on ADC pin to get some sort of feedback and run a closed loop for adjusting the duty cycle accordingly.[/quote]
Do you plan on voltages over 5 V ?  If so, then you'll need a voltage divider instead of just a series resistor.  Also, if VUSB drops below 5 V then the ADC input won't accept 5 V, so you might still need the divider.[/quote]

Actually the bp already has a voltage divider (2x10k) so when you add a series resistor of 20k the range would be 13v2 instead of 6v6.

I dunno how fast the feedback/control loop is but is a small switcher ic not an better option. You need to set it once and forget about it. The voltage divider could be some resistors and a 4066 to switch them.

datasheet: http://www.fairchildsemi.com/ds/FA/FAN5331.pdf (http://www.fairchildsemi.com/ds/FA/FAN5331.pdf)
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 12, 2011, 11:21:05 am
Feedback/control loop can be run as an interrupt. I have used them before: ADC interrupt sets a value in PWM duty cycle. Or ADC interrupt can write the reading to a buffer and PWM interrupt can read the buffer to change duty cycle. I've used first one before with position control problems and they were pretty fast. We won't have a changing current demand and it is pretty small, so that won't be a problem IMO.

Switcher IC is good but then we don't support arbitrary voltage levels. Also it uses more pins (lets say one each for different voltages) whereas feedback just uses 2 pins (ADC and PWM)
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: BrentBXR on December 13, 2011, 03:13:11 am
Hopfully im not imposing on any current convos or reasking a question already awnsered. but I read somwhere (or thought anyways) that Ian had plans to order ~100 and put the programmers back into production, or atleast a fun run :D

Im just wondering if this can be confirmed and if so, is there a date set (ima mark my calender)

Also out of curiosity and if so; Are we going to be seeing a new revision on the first? perhaps with some of the 'maybe not now but future' design considerations?

Oh and also; what version BP will it be for? Now that BP 4 has different pin configuration. I have both so ill be good ;P
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: ian on December 13, 2011, 08:35:20 am
I will talk about this in todays video blog too :) Yes, ordering 100. Need to get a different connector due to Ian-stupidity, so I have not actually ordered the production yet. It will be the same as the original and v3 only, no part updates.
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 13, 2011, 02:46:38 pm
Today I looked at Ladyada's boost converter tutorial (http://http://www.ladyada.net/library/diyboostcalc.html) (has a nice calculator for values), did some fiddling around and liked these values for input:
- Frequency: 125 kHz (We use 16MIPS, this gives us 7 bit resolution for duty cycle, the bigger, better for inductor size)
- Min Vin: 4V (We will use 5V input, this is the minimum USB supply)
- Max Vin: 5V (We might get this, but usually sth like 4.9V)
- Min Vout: 8V (Giving some head room, low power pics require 8.5V, right?)
- Max Vout: 18V (Some max value I close, we can do with lower voltages maybe?)
- Iout: 0.01Amps (This is a bit over estimation, but bigger, the better for inductor size. We also include feedback voltage divider current here)
- Vripple: 0.1V (Affects output cap value)

The results I got were:
- Min. Duty Cycle: 37.5%
- Max. Duty cycle: 77.777%
- Min. Inductor size: 468.75 uH (Will get a 470 uH inductor)
- Peak inductor current: 0.062 A (Found a 0.9A inductor, perfect!)
- Minimum capacitor: 0.7999 uF (So, 1uF is enough)
- Minimum Schottky diode: 18V 0.062 A

So the parts I'll get are:
- 470uH, 0.9A inductor (http://http://akizukidenshi.com/catalog/g/gP-03060/)
- 100V 1A Schottky diode (http://http://akizukidenshi.com/catalog/g/gI-00126/)

Now have to figure out a transistor, I'm thinking an NPN transistor like this (http://http://akizukidenshi.com/catalog/g/gI-00881/).

Any ideas or suggestions before I go shopping on weekend? :) I'll breadboard it and give you some results hopefully by the weekend.
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: Sjaak on December 13, 2011, 03:19:47 pm
Most switching powersupplies use a fet. As I understand (but i'm a digital guy) these have a small on resistance.

You are going to akihabara? :D
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: BrentBXR on December 13, 2011, 03:44:42 pm
[quote author="Sjaak"]You are going to akihabara? :D [/quote]

hah, i was thinking the same thing. If you ask me; Akihabra is like cheating. :D You should have to order by mail and wait like the rest of us :D
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: Sjaak on December 13, 2011, 03:57:23 pm
offtopic: I was just asking because I did forget to get something over there :)

These parts you can also obtain easily at your local electronics shop.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: BrentBXR on December 13, 2011, 04:10:23 pm
even further off-topic: :( I dont have any electronic parts store that i know of near me. there is a nice size reseller right next to me but they dont have a store; which sucks.
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 13, 2011, 04:26:20 pm
[quote author="Sjaak"]Most switching powersupplies use a fet. As I understand (but i'm a digital guy) these have a small on resistance.[/quote]
That's totally true, they use MOS-FETs. But this being a prototype I guess I can do with an NPN transistor. In that tutorial, there is a IRFD110 (N-ch MOS-FET)driven directly by a uC pin, which is weird, usually you have to use some sort of driver IC or sth. I can try the same thing once I have a little time to look at that schematic (just came back from hackerspace).

[quote author="Sjaak"]You are going to akihabara? :D [/quote]
Of course, where else I'll get my parts in short time? :)

[quote author="BrentBXR"]hah, i was thinking the same thing. If you ask me; Akihabra is like cheating. :D You should have to order by mail and wait like the rest of us :D[/quote]
I do that too, some parts are not found in Akihabara (especially some SMD stuff) so I use Digikey, Mouser etc too. :) But for most shopping there is Akihabara. :D
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: ian on December 13, 2011, 06:52:28 pm
We also have a parts order going out tomorrow, if I can add anything small to it.

Usually SMPS is with a FET, but I have done it with a NPN too (less current available though).

I would use a 3-10uF tantalum for the cap.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 13, 2011, 09:12:48 pm
I guess I'll try some local parts here and breadboard the design first. Later we can organize sth for the prototypes maybe.

I checked out the available FETs, here are they for price etc comparison (they have pdf datasheets too):
- 2SK2232 (http://http://akizukidenshi.com/catalog/g/gI-02414/) with Vth = 0.8-2.0V
- 2SK2936 (http://http://akizukidenshi.com/catalog/g/gI-00035/) with Vth = 1.5-2.5V
- PJP75N75 (http://http://akizukidenshi.com/catalog/g/gI-04289/) with Vth = 1.0-3.0V
- 2N7000 (http://http://akizukidenshi.com/catalog/g/gI-03918/) with Vth = 0.8-3.0V
- 2N7002K (http://http://akizukidenshi.com/catalog/g/gI-04256/) with Vth = 1.0-2.5V (SMD!)

I really liked the 2N7000 and 2N7002K ones, they are small and cheap! I'm adding those to my shopping list.
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: rsdio on December 14, 2011, 12:28:57 am
[quote author="tayken"]In that tutorial, there is a IRFD110 (N-ch MOS-FET)driven directly by a uC pin, which is weird, usually you have to use some sort of driver IC or sth.[/quote]
What do you mean? I drive the gate of FETs with a PIC I/O pin all the time. As long as the gate on threshold is positive, you don't need any interface, not even a current-limited resistor. The challenge is for an FET that requires a negative gate voltage.

EDIT: I just grabbed the IRFD110 data sheet, and VGS(th) is minimum 2 V, maximum 4 V, so as long as your uC is running 5 V I/O outputs then you should have no problem driving the Power MOSFET directly.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 14, 2011, 09:26:59 am
It was my first time seeing sth like this. I just used FETs in university and they always wanted us to use some driver IC, I guess the threshold voltage was higher than 5V for those ones.

OK, so I'm fine with the above selections. There were some with max 4V, which got eliminated pretty quickly. Last two are my favorite, will try them when I get the chance.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: ian on December 14, 2011, 10:15:58 am
For eg. a nixie tube power supply with 180V out, usually the FET needs >5volts (at least >3.3volts), for small stuff like this though we have a few more options in the logic level range.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 14, 2011, 10:39:17 am
Plus voltage and current ratings are enough too: Both have Vdss as 60V and Id 200mA and 300mA respectively. I don't know what else to check, all the values seem fine to me.
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: Sjaak on December 14, 2011, 10:48:33 am
Just try it :)
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: ian on December 14, 2011, 11:54:31 am
It will go pop and make magic smoke if you got it right :)
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 14, 2011, 04:38:40 pm
[quote author="ian"]It will go pop and make magic smoke if you got it right :)[/quote]
Riiiiiight... I see what you did there :D
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 27, 2011, 07:26:21 pm
OK, finally had time to fiddle with this. The mosfet works really well with 3.3v gate voltage, I was able to switch it on/off by using the AUX pin. Then I laid out the basic boost circuit and hacked continuous ADC measurement function for a quick and dirty way to try it out. Here is the hacked function:
Code: [Select]
// hacked for smps mode
void bpADCCprobe(void)
{ unsigned int adc, PWM_dutycycle, V_out;

    consumewhitechars();
    V_out = getint(); // Output voltage in centivolt
if (V_out>1300){ // Upper limit of our ADC
return;
}
    PWM_dutycycle = 128-(500/V_out); // Duty cycle in 7 bits
V_out = V_out*45/58; // Change to 1024 bit ADC reading to make comparison faster

    //assign pin with PPS
    BP_AUX_RPOUT = OC5_IO;
    OC5R = PWM_dutycycle;
    OC5RS = 0x7F; // Set PWM period to 125 KHZ
    OC5CON2 = 0x1F;
    OC5CON = 0x1C06;                 

while(!UART1RXRdy()) // wait for keypress
{ AD1CON1bits.ADON = 1; // turn ADC ON
adc = bpADC(BP_ADC_PROBE);
AD1CON1bits.ADON = 0; // turn ADC OFF
if(adc > V_out){ // if output voltage is higher than requested voltage
OC5R = 0x00; // turn PWM off temporarily
}else{
OC5R = PWM_dutycycle; // othervise resume operation
}
}
UART1RX();
bpWline(""); // need a linefeed :D
}
It compiles fine, I export it and upload it with the bootloader. However, when I try to run it, my BP turns off. I have to reset it. I tried the code without plugging it in, again the same problem, so I was not able to test if I have an output on AUX pin. I don't know what is causing the problem and didn't have time to debug properly. Tomorrow I'll try to move the code to servo function and use the settings there.
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 27, 2011, 07:33:39 pm
Upppsssss, I do see a bug now:
Code: [Select]
PWM_dutycycle = 128-(500/V_out);   // Duty cycle in 7 bits
Should be corrected, actual formula is:
Code: [Select]
PWM_dutycycle = (1-500/V_out)*128;
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 28, 2011, 03:56:01 am
So apparently I had two bugs on the code: one is the one I talked about in my previous message (which was the reason why BP was turning itself off, it basically short circuits the device), the other was getint() function. I changed it to getnumber() function which also does the range test, now it works really good. The voltage readout from my voltmeter is about 40mV higher than my request but that is OK. Here is the hacked function, also I'm attaching the hex file for others to try:
Code: [Select]
// hacked for smps mode
void bpADCCprobe(void)
{ unsigned int adc, PWM_dutycycle, V_out;

    consumewhitechars();
    V_out = getnumber(0,550,1300,0); // Output voltage in centivolt

    PWM_dutycycle = 128-(64000/V_out); // Duty cycle in 7 bits
V_out = V_out*45/58; // Change to 1024 bit ADC reading to make comparison faster

    //assign pin with PPS
    BP_AUX_RPOUT = OC5_IO;
    OC5R = PWM_dutycycle;
    OC5RS = 0x7F; // Set PWM period to 125 KHZ
    OC5CON2 = 0x1F;
    OC5CON = 0x1C06;                 

while(!UART1RXRdy()) // wait for keypress
{ AD1CON1bits.ADON = 1; // turn ADC ON
adc = bpADC(BP_ADC_PROBE);
AD1CON1bits.ADON = 0; // turn ADC OFF
if(adc > V_out){ // if output voltage is higher than requested voltage
OC5R = 0x00; // turn PWM off temporarily
}else{
OC5R = PWM_dutycycle; // othervise resume operation
}
}
// Cleanup
OC5R = 0;
    OC5RS = 0;
    OC5CON2 = 0;
    OC5CON = 0;   
UART1RX();
bpWline(""); // need a linefeed :D
}

In the final version ADC interrupt should be enabled and the output voltage check and pulse adjustment should be done in the interrupt. But yeah, we now can have a boost converter shield for PIC programming and other purposes. :)

PS. No magic smoke during these tests. Damn, I really wanted to earn that magic smoke badge from Adafruit! :P
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: ian on December 28, 2011, 09:25:14 am
Nice work! I saw this really late last night and wanted to suggest a short turning it off, but it looks like you got it yourself.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 28, 2011, 10:43:08 am
[quote author="ian"]Nice work! I saw this really late last night and wanted to suggest a short turning it off, but it looks like you got it yourself.[/quote]
Yeah, apparently my duty cycle was so big that I was drawing too much current and basically shorting the device. Will take some pictures for my results, PWM wave with OLS, some different values tried etc. and post them here. I guess we have a board design for this in SVN (ok, looked it up, it is for the old version). I can try to whip up a schematic too if you want. Currently I don't have sth to switch voltage on/off, it may be a good idea to put sth right after the output of boost converter to switch it.
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on December 29, 2011, 01:57:01 pm
OK, so here are the pictures, sorry, a bit blurry because the lighting in my room is not good enough for my cellphone camera. First one is the PWM signal measured. I tried to catch the skipped pulses too but no luck there...
[attachment=2]
Second one is my test setup on my desk: BPv4 on the left, breadboarded circuit in the middle, multimeter connected to the output is on the right.
[attachment=1]
I did a couple of tests, but the best picture that displays serial console is the one where output voltage is set to 13 V. Multimeter output is 13.2 V which is strange as yesterday the difference was only 40 mV but now it is about 200 mV.
[attachment=0]
Usage is pretty easy, you turn on power supplies with W, then D (as I hacked continuous ADC mode). After this you have to enter a voltage in cV. To exit this mode, you just have to press a key. Ramp up speed is really good, it reaches 13 V in less then a second.

I will clean up my code a bit, so that when SMPS is on, other functions can still be used. Currently this is really limiting.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: ian on December 30, 2011, 09:50:59 am
Nice job! I'll post a little preview on the blog :)
Title: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on January 15, 2012, 06:55:38 am
I did some work, I've created a new library (smps.c and smps.h) which contain the bpSMPS() function that I'm running. I've included the ADC interrupt, it still blocks the command line but I'll do the change once I finish drawing the schematic later today. I had to make some additions to procMenu.c, I've assigned the bpSMPS() function to M for sMps (I searched for a while, you might want to change it). It has the same license header as the rest. I'm committing all the files, I put a little if define check to include the code only with v4 hardware. I'm hoping that I didn't break anything, but if I did, let me know.
Title: Re: Re: Where to got a PicProgrammer adapter for BusPirate?
Post by: tayken on January 15, 2012, 10:43:43 am
OK, blocking issue is solved, I tested out UART communication while boost circuit was working. Also initial schematic is uploaded.
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: ian on January 16, 2012, 02:18:30 pm
Nice work, thank you. Where did you put the schematic? I have not been able to find it.
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on January 17, 2012, 01:38:38 am
[quote author="ian"]Nice work, thank you. Where did you put the schematic? I have not been able to find it.[/quote]
It is under Bus_Piratehardware-otherPiratePICprog, named as bp_pic_programmer_v2.sch

There are 2 unconnected signals (PWM and VPPEN), did a few corrections just now. For being able to use the same binMode messages, maybe it is better to move PWM to AUX1 or AUX2. I'll also add a binMode message for PiratePICProg. A 2 byte message where the first 4 bits tell it to start SMPS, remaining 12 bits give the voltage request: max value supported is 1300 cV = 13 V (at least in the terminal, with getnumber function), that is a 11 bit number, with 12 bits, we can go up to 4095 cV = 40 V, but we have to change the value of the feedback resistor from 20k to something larger for higher voltages than 13 V.

After schematic is finalized, I'll start routing.
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: ian on January 17, 2012, 09:35:56 am
Looks great to me.

In v1 (let's call it v3 now, and this v4...) we used AUX for VPPEN, which is why we couldn't do the simple SMPS style. AUX0 is already PWM, so that makes sense, but if it is easier with binmode it is only 1 or 2 lines of code to move it elsewhere. It is really up to you which pin is best :)

I would keep it locked at 13volts for now, that's enough for most stuff.

In a future revision maybe we can add a AVR high-voltage programming header for fuse rescue.
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on January 17, 2012, 03:23:27 pm
[quote author="ian"]In v1 (let's call it v3 now, and this v4...) we used AUX for VPPEN, which is why we couldn't do the simple SMPS style. AUX0 is already PWM, so that makes sense, but if it is easier with binmode it is only 1 or 2 lines of code to move it elsewhere. It is really up to you which pin is best :)[/quote]
OK, lets use AUX0 for VPPEN and PWM with AUX1. It is just one simple change in code so no worries there.

[quote author="ian"]I would keep it locked at 13volts for now, that's enough for most stuff.[/quote]
So limited to 13 V it is.

[quote author="ian"]In a future revision maybe we can add a AVR high-voltage programming header for fuse rescue.[/quote]
OK, got that. Checking out high voltage programming as I have no knowledge. Seems like nearly all the signals are the same except reset pin, which needs 12V?
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: ian on January 17, 2012, 06:07:22 pm
Quote
OK, got that. Checking out high voltage programming as I have no knowledge. Seems like nearly all the signals are the same except reset pin, which needs 12V?

Leave it for v2 :) I've done a bit of research before, but I don't recall it now. At one time I know enough to put the framework in place for someone else to add the code to avr dude or whatever, I'll come up with something. I'd rather get this out and available as a v4 programmer to support Pirate PIC prog than worry about AVRs ;)
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: Sjaak on January 17, 2012, 09:40:34 pm
There was a discussion about this in the old picprogrammerthread.. The problem was the BP v3 didn't have enough pins, so avr support was dropped. If I recall correctly it lacks two pins.
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on January 18, 2012, 08:37:02 am
[quote author="ian"]Leave it for v2 :) I've done a bit of research before, but I don't recall it now. At one time I know enough to put the framework in place for someone else to add the code to avr dude or whatever, I'll come up with something. I'd rather get this out and available as a v4 programmer to support Pirate PIC prog than worry about AVRs ;)[/quote]
Yep, that's what I was thinking. :) I just did some research for the future revision. :)

Committed final schematic and code. Will try to finish routing today.
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on January 19, 2012, 03:03:07 pm
Routing finished and committed to SVN. Any feedback is welcome. :)
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: robots on January 19, 2012, 03:57:33 pm
nice :-)
it could be smaller
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: ian on January 20, 2012, 11:49:59 am
Nice work. The SMPS is night and straight and tight. I might thicken up the SMPS traces a bit.

It is stackable so the T4 isn't really under a shrouded header?

I would bring their power input via to the SMPS over to the right side of C2

Corner holes should probably be larger. Maybe it fits on one of the standard boards checked into the library SVN?
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on January 20, 2012, 12:50:25 pm
[quote author="ian"]Nice work. The SMPS is night and straight and tight. I might thicken up the SMPS traces a bit.[/quote]
I've used 24 mil traces all around the board. I can make SMPS traces a little thicker if you want. These traces should be good for currents up to ~1 A.

[quote author="ian"]It is stackable so the T4 isn't really under a shrouded header?[/quote]
It is actually a female header mounted the same way as in the version for v3. I just copied it from one of the schematics to get the pin names quickly. I can change it to a regular female header to clear up things.

[quote author="ian"]I would bring their power input via to the SMPS over to the right side of C2[/quote]
There are lots of traces going around and I was a little bit tired at the time. I'll try to get it somewhere there.

[quote author="ian"]Corner holes should probably be larger. Maybe it fits on one of the standard boards checked into the library SVN?[/quote]
Those are actually vias connecting top ground layer to the bottom ground layer. Might add a little more. Current board size is 1.4 by 1.3 inch.
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on January 20, 2012, 03:45:29 pm
OK, did some changes. Routing and some parts placements changed, power input comes from the right side now. But as that trace goes under the pin header, I was limited by 24 mils which is the trace width I used throughout the board. Board size is now 1.3 by 1.1 inches.

Maybe some labeling cleanup is needed but I guess only some minor adjustments are needed now.
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on January 26, 2012, 03:14:02 pm
Did some label cleanup, followed Sjaak's advice on some parts placement and added pin function descriptions.  Thinking about getting rid of the ICSP header with triangle and using a normal pin header in order to be able to place MCLR label better. There is some space in the bottom right side which can be used for DP logo.

Any other ideas?
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on April 22, 2012, 12:58:04 pm
And we have working prototypes!

Had to test out with a multimeter and user mode commands, will add binmode commands and modify the test program for the V4 adapter later tonight.

Here is a picture of this beautiful thing:
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: Sjaak on April 22, 2012, 07:50:03 pm
I love the smell of built prototypes !
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: ian on April 23, 2012, 10:17:51 am
Yeah! Nice work!
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on April 23, 2012, 10:57:46 am
Had a problem last night while I was messing around. First SMPS started acting weird, I was requesting 9 V but it was giving about 12.8 V then I tried a couple of stuff and this time there was no communication, BPv4 was not being recognized by my PC. I'll try to figure out the problem before I go on...
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: ian on April 23, 2012, 11:33:19 am
Maybe a short or too much current draw reset the PIC? On some LCD projects I use PWM to ramp up the backlight because switching it on resets the board (even with 100uF caps).

If your Bus Pirate is dead please let me know asap and I'll send out another one.
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on April 23, 2012, 05:13:23 pm
[quote author="ian"]If your Bus Pirate is dead please let me know asap and I'll send out another one.[/quote]
Loading the "official" firmware solved that problem. Selftest results are OK, no errors. Probably something to do with firmware.

Hmm, probably I messed sth up while exporting the firmware. Loaded official firmware, OK, loaded the last one I compiled, no good, does not get recognized, recompiled the firmware and exported it, got it to work. Probably I shouldn't mess with stuff late at night :)

One thing that worries me: We have some overshoot, with 9 V request, output is ~9.45 V and 12V request it is ~12.8 V I'm trying to calm myself down thinking that we'll have some voltage drop with the transistors so it should be OK.

Regarding bitbanging mode: Next raw protocol mode is 0b00000111, I'll be reserving this for enabling SMPS. After this there will be special commands for setting output voltage and starting, reading ADC (will be easy as I already get it by interrupt), turning off the SMPS and returning to bitbang mode. Anything else that comes to your mind?
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: ian on April 24, 2012, 07:55:34 am
Maybe the ADC control stuff can go with the other PIC commands in the raw2wire binary mode? Then it is all in the same place.
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on April 24, 2012, 05:18:38 pm
We have all PIC commands in 7 (0b0000 0111) which is not documented :S. I am nearly done with writing the codes have to finalize where everything goes. I am thinking about using binary command 8 for SMPS mode. Probably we will use this for testing. I cannot wrap my head around how to do implement this in others as binPIC has all commands consumed except those start with 0b0010xxxx and 0b0011xxxx maybe I can use these ones?
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on April 24, 2012, 09:13:35 pm
OK, so the codes are at the SVN now. I used 8 to enter SMPS mode, just to quickly try it out. Later on this will be moved to somewhere else, possibly under pic.c as that is what we're using wit PiratePICProg (I guess?).

One thing to note is pic mode is not documented at wiki, I'll try to document it once I have time tomorrow, I always get bored at the lab. :)

Here is the usage:
8 enters the SMPS mode, returns "SMPS1". From there you have a couple of commands:
- 0 returns to binmode
- 1 for version string, returns "SMPS1"
- 2 for starting up. It turns on the voltage regulators, gets 2 bytes from the terminal as the requested voltage and starts SMPS operations.
-3 for shutting down. We stop SMPS and turn off the voltage regulators.
- 4 for getting the ADC value, same as the binmode command, it returns the ADC reading as 2 bytes. I used a separate variable to store ADC buffer for this. Just to be on the safe side.
Title: Re: PicProgrammer v2 for BusPirate v4 Development
Post by: tayken on April 26, 2012, 07:16:18 pm
Well, as for latest development, I ported all binmode commands to binwire.c as we are using that for PIC programming purposes. All unnecessary commands are removed from smps.h and smps.c files, removed the entry to SMPS mode from binIO.c (8 is free now) also freed up 'M' command I was using in user interface menu. The new commands when you enter binary raw-wire mode are:
- 11110000 - Return SMPS output voltage
- 11110001 - Stop SMPS operation
- 1111xxxx - Start SMPS operation (xxxx and next byte give requested output voltage): Lowest possible value is 512 = 0b0010 0000 which is normal as our minimum voltage output is > 5 V. Also we have a 12-bit number which can be used to represent voltages up to 4095 cV

Uploading code to SVN now.