Woes of tinkering: Sleep

Constant Current Load gremlins: 2

Me: 0

Leaving a project in the middle of getting your @$$ handed to you is no fun. I hope I’m not the only one who gets a little frazzled when I have to leave the work bench before I get to fix the “big hold up”.. or magic bug.. or whatever it is that’s keeping your blinking light from doing it’s thing.

Kerry Wong came up with a Constant Current Load that was tweeted the other day. I bought some parts from digikey and went to work this weekend. Friday evening I designed and etched a simple board for the IRFP150Ns and shunts… then Saturday I had a little time in the morning and strip boarded the op amp circuit with a potentiometer input. I have a PIC dev board I bought from ebay that I’ll use but I’ll go into that another day. Saturday we lost power in a storm and Sunday I was suckered into installing wall heaters for my sister.. so a very tired Monday and Tuesday evening I have been tinkering with this thing… it’s not entirely obvious what I did wrong… probably a little error I’ll catch after catch up a bit on sleep.

I’m planning on using this for a constant current power supply. I believe Dave (EEVBlog) or perhaps someone else came up with a similar idea but they were using it for a way of testing batteries. I recommend just buying a West Mountain Radio CBA (computerized battery analyzer) if that’s the route you are going. The software is  pretty decent. I have a CBA-III but it only works on Windows XP.. I was pretty annoyed when they didn’t come out with a user updatable firmware patch for Windows 7. It’s a solid tool if you work with SLAs  or lithium batteries regardless of my little rant a couple years back.

So my primary laptop is a 1 year old Vaio that took a nasty dive at a science fair I was demonstrating my Sumo RoombaBot for a high-cap school. The USB boards died because it sheered the driver off the PCB and blew out traces, etc… no fixing it anyways. I have an old XP laptop I program for now but I was considering one of these Windows Surface 2 tablet/laptops but they only have 1 USB port… that or perhaps I’ll just suck it and buy another Vaio!? Choice choices. Anyone reading used a Microsoft Surface for any development work at all? Spice?, MPLAB?, anything besides email and browsing? Shoot me a reply or e-mail. Thanks!

Quick and dirty Hello World, PIC 16F1509 + 4 Bit 44780 format LCD

Okay… nothing magical here. Just a boring old “Hello World”. There doesn’t seem to be any sample code for the newer enhanced mid-range PICs with a LCD that I could find online; perhaps you can find something better with Google than I will.

I promise you two things with this code: It’s fresh off the press so it’s ugly, sloppy, poorly commented, I didn’t use pagesel at all, it’s probably buggy as sh%t and it’s slow. Remember 300 baud modems and BBS chat rooms? yeah…. déjà vu. I was having problems with timing and I don’t have a proper logic analyzer and I didn’t care to do all the math.. so I went safe. In fact after pasting the code I see a huge obvious flaw as it is, you’ll see it, but anyways it’ll display Hello World. Enjoy.

Full disclosure: I was heavily inspired by this code as a building block from piclist.. mostly I wanted a quick and dirty way to go 4 bit.

lcd_16f1509

;*******************************************************************************
; PIC 16F1509 LCD Test
; http://iradan.com
;
; ver 0.01 Hello World 4 bit, extra-dirty.
;
;*******************************************************************************
errorlevel -230, -302, -303
 LIST R=DEC
#include "p16f1509.inc"
 __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _CLKOUTEN_OFF
 __CONFIG _CONFIG2, _LVP_OFF & _STVREN_ON
;*******************************************************************************
;Device 16F1509
;
; PIN DIAGRAM
;
; RA0 O x RC0 O LCD_1/11
; RA1 I x RC1 O LCD_2/12
; RA2 I x RC2 O LCD_3/13
; RC3 O LCD_4/14
; RA4 O x RB4 I RC4 O LCD_E/6
; RA5 O x RB5 O x RC5 O ?FUTURE _ PWM?
; RB6 I RC6 O 
; RB7 I RC7 O LCD_RS/4
;
;*******************************************************************************
;
GPR_VAR UDATA
R_SEND_TMP RES 1
R_SEND_W_TMP RES 1
R_WDATA_TMP1 RES 1
R_WDATA_TMP2 RES 1
int_delay1 RES 1
;*******************************************************************************
; Reset Vector
;*******************************************************************************
RES_VECT CODE 0x0000 ; processor reset vector
 GOTO START ; go to beginning of program

;*******************************************************************************
; MAIN PROGRAM
;*******************************************************************************
MAIN_PROG CODE ; let linker place main program
banksel OSCCON
 movlw b'01111000' ; INTOSC 16MHz
 movwf OSCCON ;
 banksel OSCSTAT ;
 btfss OSCSTAT, HFIOFR ; Running?
 goto $-1 
 btfss OSCSTAT, HFIOFS ; Stable?
 goto $-1
goto START
;-------------------------------------------------------------
w_to_data
 BANKSEL PORTC
 movwf R_WDATA_TMP1
 movf PORTC, W
 movwf R_WDATA_TMP2
 bcf R_WDATA_TMP2, 0
 bcf R_WDATA_TMP2, 1
 bcf R_WDATA_TMP2, 2
 bcf R_WDATA_TMP2, 3
 btfsc R_WDATA_TMP1, 0
 bsf R_WDATA_TMP2, 0
 btfsc R_WDATA_TMP1, 1
 bsf R_WDATA_TMP2, 1
 btfsc R_WDATA_TMP1, 2
 bsf R_WDATA_TMP2, 2
 btfsc R_WDATA_TMP1, 3
 bsf R_WDATA_TMP2, 3
 movf R_WDATA_TMP2, W
 movwf PORTC
 return
pulse_e
 BANKSEL PORTC
 bsf PORTC,4
 call delay2
 BANKSEL PORTC
 bcf PORTC,4
 call delay2
 return
send_w
 movwf R_SEND_W_TMP
 swapf R_SEND_W_TMP, F
 movlw 0x0F
 andwf R_SEND_W_TMP, W
 call w_to_data
 call pulse_e
swapf R_SEND_W_TMP, F
 movlw 0x0F
 andwf R_SEND_W_TMP, W
 call w_to_data
 call pulse_e
 return
delay2
 BANKSEL int_delay1
 MOVLW 0x01
 MOVWF int_delay1
OLOOP
 BANKSEL TMR0
 CLRF TMR0
 BANKSEL INTCON
 BCF INTCON,T0IF
 MOVLW 0xC0 ; PortB pull-ups are disabled, (c3=1:16)
 MOVWF OPTION_REG ; Interrupt on rising edge of RB0
 ; Timer0 increment from internal clock
 ; with a prescaler of 1:4.
; The TMR0 interrupt is disabled, do polling on the overflow bit
T0_OVFL_WAIT2
 BTFSS INTCON, T0IF
 GOTO T0_OVFL_WAIT2
NOP
 BANKSEL int_delay1
 DECFSZ int_delay1,1
 GOTO OLOOP
 NOP
 ;... else
RETURN
START
BANKSEL PORTA
 CLRF LATA
 BANKSEL PORTB
 CLRF LATB
 BANKSEL PORTC
 CLRF LATC
 CLRF PORTC
 BANKSEL ANSELC ;
 CLRF ANSELC ;Digital IO
 BANKSEL PORTC ;
 CLRF PORTC
 BANKSEL TRISC ;Set all PORTC to outputs
 CLRF TRISC
 BSF PORTC,6

movlw b'11000111' ;configure TMR0
 BANKSEL OPTION_REG
 movwf OPTION_REG
; GOTO LOOP ;<--------------DEBUG
 BANKSEL PORTC
 bcf PORTC,7 ;LCD_RS
 movlw 0x02 ; Still in 8-bit, so appears as 0x20 to LCD
 call w_to_data
 call pulse_e
call delay2
movlw b'00101000'
 call send_w
movlw b'00001110'
 call send_w
movlw b'00000110'
 call send_w
call delay2
BANKSEL PORTC
 bcf PORTC,7 ; Command mode
; movlw b'00000010' ; Return cursor to home
; call send_w
 movlw 0x80
 call send_w
 BANKSEL PORTC
 bsf PORTC,7 ; Data mode
 call delay2 ; Takes a couple of ms
movlw 'H'
 call send_w
 movlw 'e'
 call send_w
 movlw 'l'
 call send_w
 movlw 'l'
 call send_w
 movlw 'o'
 call send_w
 movlw ' '
 call send_w
 movlw 'W'
 call send_w
 movlw 'o'
 call send_w
 movlw 'r'
 call send_w
 movlw 'l'
 call send_w
 movlw 'd'
 call send_w
 movlw '.'
 call send_w
LOOP
 ;
NOP
 BANKSEL PORTC
 BCF PORTC, 5
 call delay2
 BANKSEL PORTC
 BSF PORTC,5
 call delay2
 GOTO LOOP ; loop forever
END

	

Microchip TC649 PWM Fan Controller Checkout

It’s Friday, my wife is off head-shrinking so I decided the first thing out of the box of goodies I just got from Digikey was going on the breadboard. Okay… so I lied to myself: a 74HC14… those are just restocking parts from a project I was working out that W2AEW had posted on his YouTube channel (the link is to the Youtube channel, if you’re not subscribed, you’re missing out.) So off to the next part.. A Microchip TC649 ?? What was that again? I don’t know about you but I just put random stuff that looks cool in my Digikey shopping cart until I am ready to place an order for stuff I actually need. Maybe I saw this in an Elektor article? Got me.. but hell PWM Fan Speed Controller with FanSense[TM]… neat! I downloaded the PDF to check it out; I was thankful I didn’t need to break out some i2c to get it running, it’ll run standalone with a thermistor. There is an example of using a microcontroller, I imagine I’ll use close to how their example design is shown. So, embarrassing, I know I have thermistors but I don’t know where they are? I used a 10k 10 turn pot. The Tc649 is looking for 2.7-1.8v No problem. I had a small fan so I used a 2N2222 and 810Ohm resistor for R_BASE. I recommend doing the math on the sense resistor (or it won’t pick up your stall) … They have a nice chart as well in the manual. I HIGHLY recommend sticking with 1uF for the PWM cap.. I played around with that, there is a reason they recommend it. In fact you’ll see my screen shots below are with a 0.47uF cap but the fan stalled while running faster than with 1uF. Not a lot more to say about this? It works! Very well in fact. The fan can just about be completely stalled with your finger (if you’re brave!)  and it’ll continue to run… but you’ll be recycling power unless you build a reset into the circuit (I hadn’t). My circuit was running 5V, fan was on 12VDC (oh yeah, you can use “any fan voltage”) . I’ll hook this up to the first microcontroller to come out of the box later on this weekend! Until then.

 

Microchip TC649 Design Example that I used for my initial breadboard experimentation.
Microchip TC649 Design Example that I used for my initial breadboard experimentation.

 

Channel A: Output to R_BASE on it's way to a transistor ( 2N2222 )  Channel B: Pin 5 (Sense)
Channel A: Output to R_BASE on it’s way to a transistor ( 2N2222 )
Channel B: Pin 5 (Sense)
Channel A: PWM output to R_BASE and on to the transistor  Channel B: Capacitor Cf (shown with 0.47uF) determines the frequency of of the PWM.
Channel A: PWM output to R_BASE and on to the transistor
Channel B: Capacitor Cf (shown with 0.47uF) determines the frequency of of the PWM.

VFD Update: In Precharge / Configured

Slowly chiseling away. I got the terminals set up, all the motor set up, disabled most faults in advanced configuration and I now have the drive out of fault, temp sensor back working, and ready to drive waiting on the DC bus.

I think if I read the manual right with my configuration that should be about 370VDC, but I guess we will see? The VTAC9 Rockwell Automation manual is really detailed in some regards but lacking in regards to technical information. Not surprising after looking at the set up the VTAC controller has no idea it’s missing the AC input. The drive does start up right at about 196V on the DC bus … if you have to get one running just enough to configure it. I could/did configure the drive for a lower motor voltage but I won’t know if that effects the requirement for the DC bus; I doubt it.

Now.. I just need to suck it up and buy some batteries. I put in a big order with @Digikey but it’s all subsystems stuff. I’ve never worked with CAN before but the new Elektor has a article about a CAN tester and it interested me enough to try it out.

I also noticed @Sparkfun has a neat little bluetooth module out that I was considering picking up for $59 .. but then they also have a “Silver” one that’s $39 and has 3.3-6V input both Vcc and inputs. They’re small and are set up for TTL level RS-232. My current module is larger, has a lot of pins I don’t use (although I do like the handy link output).

With all this need for HV DC I’m seriously considering building a home-brew HV power supply. You have probably seen my bench I have some cheapo Elecnco 0-20/5/-12/12,  a B&K 1601, and some miscellaneous other fixed sources. I have my eyes on a B&K 9124 and a B&K 9110 (tear down: http://www.eevblog.com/forum/reviews/bk-precision-9110-60v5a-100w-psu-review-%28with-pix!teardown%29/ ).

VFD waiting 'In Precharge' after configuration.
VFD waiting ‘In Precharge’ after configuration.

VFD Update: AC retrofit to DC, Drive Start Up on DC bus.

I said I was going to wait until I had enough batteries to start this drive up but I decided I couldn’t wait. I took a 110VAC to 42VAC power supply that was lying around and fed that into the secondary of the fan transformer (690VAC tap). Through an undersized bridge rectifier I need to change out if I’m going to use it for longer than a brief start-up (400V, yes technically big enough but..). The drive started on it way up to 220VAC as the capacitors charged. I didn’t allow it to stay on long because I have no fan and I got a over temp alarm though, I think it’s not right, 110 deg C. I must have wiggled a cable out? I’ll look around as I think I know where both sensors are found.

So there it is, started up. I have a lot of reconfiguration to do to the drive to get it to run on low DC bus voltage. I was reading the manual and I think I can cheat it down…. I certainly don’t want a 680V DC bus as that’s a lot more batteries than I was planning on.  I haven’t decided if I’ll be running it by potentiometer, 0-10VDC or 4-20mA control signal … I should probably figure out how I’m going to physically request/actuate a speed demand before I decide.

Next steps: 1. Attach DC fans for the heat sink, provide a more securely wired input, configure settings…

Note: 110V  42VAC transformer fed to 110V480V transformer, rectified to supply to 220VDC. The VFD powers up in the 200V neighborhood.
Note: 110V 42VAC transformer fed to 110V690V transformer, rectified to supply to 220VDC. The VFD powers up in the 200V neighborhood.
Below is the 80W power supply board and then above that is the IGBT board with capacitors to the right.
Below is the 80W power supply board and then above that is the IGBT board with capacitors to the right.

VFD Update, Stripped the AC front end.

I removed the input AC components today. The drive had a lot of weight in components just to drive a 110V fan. I’ll obviously have to replace that AC fan with a DC fan. It won’t have the CFM output of the original but I won’t be generating the heat it had. This monster was in a building right next to I-405… you can tell is was breathing a lot of fallout it’s whole life. It’s amazing where the dirt and scum has found to hide and how much there is.

I was happy to see the only thing the AC provided power to was the cooling fan and then straight to rectifiers… that’s great news of course.

I know it was wishful thinking but I threw 160 VDC at it… didn’t even blink. I’m just going to have to wait until I can get my hands on more batteries. My 20Ah batteries are looking like they’re going to be garbage… they’re just too far gone I guess. All the recycling tricks are proving to be crap 🙂

Check out that toroid!
Check out that toroid!

Edit: that board up front is the variable voltage rectifier controller… It is also going to be removed