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

VFD Modification: Part 1

20131014-210926.jpg

First off I’ve been really tearing it up in my nerdery the last two weeks… It’s messy.. That happens so don’t mind the mess.

So I scored this sweet variable frequency drive (VFD) or also known as a VSD. It’s a Rockwell Automation drive that is to large for my application but it’ll work just fine. I figured I might have to tear out the entire front because I’m feeding it straight DC but they broke out DC to a terminal block ?! I’ll give it a try… I have a 96V power supply that was a long shot but it was no surprise two amps wasn’t enough just to power the electronics for configuration. It isn’t jumped to run… So this beast is a watt-hog just idling. I have a couple batteries I have to pick up in a few days; I am guessing I can start it up on a 48V/19AH string. The power down defaults to zero and I believe it’s set up to run on just enough to run the electronics. I guess I’ll see?! If this doesn’t run on DC (and maybe even if) I’ll gut the AC front end because it’s extra weight. Check out the terminal strip..DC is on the left. Also… In case you’re wondering its about 90lbs.. A lot of heat sink!

.

Hardness building…

Hardness building the last few days.. I chose a combination of .093 and .062 MOLEX connectors because I have a ton of them… and Vetco Electronics has a ton of surplus ones (at .59/.79 ea).. if you want to dig and find matches to… (hint, only like 10% of what they have has a matching gender…) I also bought about 50$ in pins and extra connectors as I know I’ll be using a ton of these. I probably should have bought more of them from digikey but I wouldn’t have ended up with the assortment. The real ugly purchase was my desire to stick with oil/moisture resistance MTW wire. I think it’s also known as appliance wire? Anyways it’s flexible, has nice thick insulation. Disclaimer: I have endless supplies of controls wire with is a  low voltage 18 ga power limited wire. Usually plenum rated. … all that wire is usually free for me. This wire isn’t really acceptable.. I spent about $70 on wire and that was totally out of left field. I found a couple spools (~80ft) of it cheaper than new and Vetco has decent prices even compared to eBay so I did buy most of it from Vetco. There is a bunch more 22 ga if someone is looking for it, I wanted 18 ga.

The stepper driver is a CENTENT CN0142 I purchased off eBay for $40. It’s very easy to us. I don’t know if it’s not totally obvious but the “direction” and “pulse” signals are open collector. You’re supplying a ground to signal input and +5VDC to the input labeled so.  Overly obvious.. well maybe. Rock solid stepper driver so far. I accelerated my Sparkfun NMEA23 motor from 2kHz to 14kHz fairly quickly in five programmed steps to get my speed up. Worked like a charm… lets see if i can still pull that off under more load.

Also of interest?  I had to boot up an old Windows 3.11 laptop to use an old programming app for some super old controls. (Okay, not 1970’s stuff… but early 90s anyways).  It’s been a while since I’ve seen that screen (photo below). I didn’t have a mouse but it magically came back to me pretty quick!

harnesses, harnesses, hardnessed....

 

Making up harnesses with painfully expensive MTW wire.

Windows 3.11

Weekend stepper fun!

20131004-130715.jpg

I got got home to take delivery of this front end frame piece. Now I’ll be busy this weekend working on electronic steering. The PIC 16F1509 will be controlling all steering functions. I’ve written a remarkable amount of code for how long it’s been since I worked I a project with a F628A and 18F1330 motor control for the Roomba sumo bot. This project has gotten painfully expensive despite scoring some nice freebies. I spent way too much on wire because I want MTW or Teflon.

DECFSZ [NOT AN] issue on the PIC 16F1509 ?

EDIT: I hate going to the message board… naturally I am licking my wounds from getting scolded for daring to use cblock…

GPR_VAR UDATA

var_name  RES 1

…. took care of this issue… at least that fiasco is over.. and I thought the PWM was going to be the hard part!  /EDIT

This code is killing me. I’ve pulled it out of something I’m working on… it has been kicking my ass for two days now.

The LED on PORTC,2 should be pulses for a few hundred nanoseconds and then go off….. right?  No.. the decfsz sits in an endless loop it seems. Why? I’ve messed up somewhere here?

 

  errorlevel -230, -302, -303, -313
    LIST R=DEC

#include "p16f1509.inc"


    __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _CLKOUTEN_OFF
    __CONFIG _CONFIG2, _LVP_OFF & _STVREN_ON


cblock
    int_delay1
    int_delay2
endc

RES_VECT  CODE    0x0000            ; processor reset vector
    GOTO    START                   ; go to beginning of program


MAIN_PROG CODE                      ; let linker place main program


INIT:
                            ;RC5 = PWM1
    BANKSEL LATA            ;Data Latch
    CLRF LATA               ;
    BANKSEL ANSELC          ;
    CLRF ANSELC             ;Digital IO
    BANKSEL PORTC           ;
    BCF PORTC,5             ;Clear PWM1
    BANKSEL TRISC           ;Set all PORTC to outputs
    CLRF TRISC

    BANKSEL OSCCON
    MOVLW   0x78            ;16MHZ Clock
    MOVWF   OSCCON

    RETURN


START
    CALL    INIT

           BANKSEL int_delay1
            MOVLW   0x01
            MOVWF   int_delay1
            BSF PORTC,2
OLOOP
            NOP
            BANKSEL int_delay1
            DECFSZ int_delay1,1
            GOTO OLOOP
            BCF PORTC,2



    NOP

LOOP:
    NOP
    GOTO LOOP                ;loop forever

    END

PWM on the PIC16F1509 in ASM

[Edit: If you’re looking for NCO (numerically controlled oscillator) usage instead of the PWM module take a look here instead. However note the code is in C (for XC8) not ASM]

Another lazy Sunday… A lot of OT the last few weeks at work and Sunday about the only day I have for relaxation so to clear my mind I wrote some test code for Pulse Width Modulation on a development board I purchased from @TINDE made by @TAUTIC . I’ll attach the code for anyone to use.

MPLAB on the laptop with a @TAUTIC / @TINDE dev board with a PWM test output.
MPLAB on the laptop with a @TAUTIC / @TINDE dev board with a PWM test output.

The code outputs on PWM1 (RC5) at about 1Khz at just under 50% duty cycle but that easy to change if you read the Microchip 16F1508/9 spec sheet section 23.

;*******************************************************************************
;                                                                              *
;    Microchip licenses this software to you solely for use with Microchip     *
;    products. The software is owned by Microchip and/or its licensors, and is *
;    protected under applicable copyright laws.  All rights reserved.          *
;                                                                              *
;    This software and any accompanying information is for suggestion only.    *
;    It shall not be deemed to modify Microchip?s standard warranty for its    *
;    products.  It is your responsibility to ensure that this software meets   *
;    your requirements.                                                        *
;                                                                              *
;    SOFTWARE IS PROVIDED "AS IS".  MICROCHIP AND ITS LICENSORS EXPRESSLY      *
;    DISCLAIM ANY WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING  *
;    BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS    *
;    FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL          *
;    MICROCHIP OR ITS LICENSORS BE LIABLE FOR ANY INCIDENTAL, SPECIAL,         *
;    INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO     *
;    YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR    *
;    SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY   *
;    DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER      *
;    SIMILAR COSTS.                                                            *
;                                                                              *
;    To the fullest extend allowed by law, Microchip and its licensors         *
;    liability shall not exceed the amount of fee, if any, that you have paid  *
;    directly to Microchip to use this software.                               *
;                                                                              *
;    MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF    *
;    THESE TERMS.                                                              *
;                                                                              *
;*******************************************************************************
;                                                                              *
;    Filename:      main.asm                                                   *
;    Date:          Sept 29 2013                                               *
;    File Version:  1.0                                                        *
;    Author:        Charles Douvier                                            *
;    Company:                                                                  *
;    Description:   Test of PWM1                                               *
;
;    Device 16F1509
;
;
;
;
; PIN DIAGRAM
;
;   RA0                             RC0
;   RA1                             RC1
;   RA2                             RC2     STATUS LED
;                                   RC3
;   RA4             RB4             RC4
;   RA5             RB5             RC5     PWM1
;                   RB6             RC6
;                   RB7             RC7
;
;------------------------------------------------------------           *
;*******************************************************************************
;                                                                              *
;    Notes: In the MPLAB X Help, refer to the MPASM Assembler documentation    *
;    for information on assembly instructions.                                 *
;                                                                              *
;*******************************************************************************
;                                                                              *
;    Known Issues: This template is designed for relocatable code.  As such,   *
;    build errors such as "Directive only allowed when generating an object    *
;    file" will result when the 'Build in Absolute Mode' checkbox is selected  *
;    in the project properties.  Designing code in absolute mode is            *
;    antiquated - use relocatable mode.                                        *
;                                                                              *
;*******************************************************************************
;                                                                              *
;    Revision History:
;           2013-09-28  Initial                                                *
;                                                                              *
;*******************************************************************************

;*******************************************************************************
; Processor Inclusion
;
;*******************************************************************************
    errorlevel -230, -302, -303, -313
    LIST R=DEC
#include "p16f1509.inc"
;*******************************************************************************
;
; Word Setup
;
;
;*******************************************************************************
    __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _CLKOUTEN_OFF
    __CONFIG _CONFIG2, _LVP_OFF & _STVREN_ON
;*******************************************************************************
;
;  Variable Definitions
;
;*******************************************************************************
; TODO PLACE VARIABLE DEFINITIONS GO HERE
;*******************************************************************************
; Reset Vector
;*******************************************************************************
RES_VECT  CODE    0x0000            ; processor reset vector
    GOTO    START                   ; go to beginning of program
;*******************************************************************************
; TODO INSERT ISR HERE
;*******************************************************************************
; MAIN PROGRAM
;*******************************************************************************
MAIN_PROG CODE                      ; let linker place main program
INIT:
                            ;RC5 = PWM1
    BANKSEL LATA            ;Data Latch
    CLRF LATA               ;
    BANKSEL ANSELC          ;
    CLRF ANSELC             ;Digital IO
    BANKSEL PORTC           ;
    BCF PORTC,5             ;Clear PWM1
    BANKSEL TRISC           ;Set all PORTC to outputs
    CLRF TRISC
    BANKSEL PORTC
    BSF PORTC,2
    BANKSEL OSCCON
    MOVLW   0x78            ;16MHZ Clock
    MOVWF   OSCCON
    BANKSEL PWM1CON         ;
    CLRF PWM1CON            ;Disable PWM bits
    BANKSEL PR2
    MOVLW 0xFF
    MOVWF PR2               ;Load PR2 with 0xFF
                            ;Timer/PR set up is 973Hz
    BANKSEL PWM1DCH
    CLRF PWM1DCH
    BANKSEL PWM1DCL
    CLRF PWM1DCL
    BSF PORTC,2
    BANKSEL PWM1DCH
    MOVLW   0x6F
    MOVWF   PWM1DCH

                            ;copied code, havent check this yet.
    ;ENABLE INTERRUPT
    BANKSEL PIE1
    BSF PIE1,1
    bcf        PIR1,2
                    ;-----------------------------------
                    ;Configure and start Timer2
;CONFIGURE TIMER.. copied code review.
    BANKSEL T2CON
    MOVLW B'00000110'   ;MOVLW B'00000110'
    MOVWF T2CON
                    ;Enable PWM output pin and wait until Timer2
                    ;overflows, TMR2IF bit of the PIR1 register is set.
                    ;See note below.
    btfss    PIR1,1                ;Test for T2 interrupt
    goto    $-1
                    ;Enable the PWMx pin output driver(s) by clearing
                    ;the associated TRIS bit(s) and setting the
                    ;PWMxOE bit of the PWMxCON register.
                    ;Configure the PWM module by loading the
                    ;PWMxCON register with the appropriate values.
    BANKSEL TRISC          ;Enable Outputs
    CLRF    TRISC
    BANKSEL PWM1CON        ;Enable PWM1
    MOVLW    B'11000000'
    MOVWF    PWM1CON
    RETURN
START
    CALL INIT
    BANKSEL PORTC            ;select PORTC for heatbeat
LOOP:
    BSF PORTC,2              ;heart beat
    MOVLW 0x55
    NOP                      ;future code
    BCF PORTC,2
    GOTO LOOP                ;loop forever
    END

 

 

Using a stepper motor as a rotary encoder

I won’t ruin the surprise on what I’m working on. No laser printer, or CNC machine for me (for now?). I borrowed the concept of using a stepper motor from this: website link.  I used a LM339 for my comparator because that’s what I had, it worked fine. I have some more testing but I’m pretty sure my low resistance coils on the stepper cause my direction accuracy to be wrong as single stepping about 20% of the time. At a slow speed it works fine. I’ll test my theory out this weekend sometime. Also shown on that 44 pin vector board as I mentioned is a SR flip-flop and some logic to latch the direction and accept a reset from a MCU once the state it read. I didn’t want to deal with any clocks. I realize I could have put that all in software but I didn’t feel like it and I have a lot of vector board to fill up 🙂   The back end of the circuit can be found on the second photo. I had put a OR gate in my written schematic to automatically reset the SR (74LS279) but I dropped it in prototyping. I just got my stepper driver for the NEMA23 stepper mounted there so that’ll make a “fun” Friday night tomorrow as it’s suppose to be rainy and a little chilly out…

Another Work-In-Progress shot.. I just got my stepper driver from eBay today shown to the left. Tomorrow I'll test it out and write some code for the encoder.
Another Work-In-Progress shot.. I just got my stepper driver from eBay today shown to the left. Tomorrow I’ll test it out and write some code for the encoder.
A stepper motor encoder with directional latch (SR Flip-Flip with MCU reset) This works okay with some minimum rotation. Single stepping isn't the best but it's likely because of the low resistance coils.
A stepper motor encoder with directional latch (SR Flip-Flip with MCU reset) This works okay with some minimum rotation. Single stepping isn’t the best but it’s likely because of the low resistance coils.