mrhobbles Posted April 5, 2012 Share Posted April 5, 2012 Hello DT forum, I need your help with a particular application. I've inherited a project that uses an Atmel Atmega328P MCU to drive a DC brush motor through a L298HN. The MCU controls the motor with a 0-5V PWM output on the L298HN's enable pin and two additional MCU pins are used as a 0-5V signal on L298HN's Inputs 1 & 2(CCW & CW). I've tried following the User Manual under Special Instructions for Direc t-PWM Control of Brush Motors pg 100 but am not understanding the results I get. On Output C(JMACH2 Pin 13) I get a square wave like I expect from a PWM output 0 to +5V, but Output A(JMACH1 Pin 29) is more of a sine wave from -5 to 5mV. This is my code for a simple output test using the open loop output command "o{constant}". I download the file to PMAC and then check the output on the scope. /* Configure channel 1 for open loop motor control */ I100 = $0 ;Disable Motor 1 I7016 = $0 ;A & B are DAC & C is PWM I124 = $130001 /* Disable Amplifier Fault Use B20 = 1 Overtravel Limit Use B17 = 1 Amplifier Enable Use B16 = 1 Flag Reg Type PMAC2 Style B0 = 1 */ I111 = $0 ;Disable Following Error Limit I112 = $0 ;Disable Following Error Warning I125 = $78000 ;Point to address of Flag bits in IC I100 = $1 ;Enable Motor 1 And my code that tries to follow the Special Instructions for Direc t-PWM Control of Brush Motors pg 100 and is unresponsive to my open loop commands. /* First Attempt*********** Follow the direct PWM setup for brush motors in the Pmac user manual. Pg.100 */ I100 = 0 I101=1; PMAC handles commutation for Motor #1 I102=$78002; PMAC DAC 1 on Clipper, becomes Phase A output I182= 0; PMAC isn't closing current Loop I129=0 I179=0 I161=0 I162=0 I176=0; Related to Loop current I173=0 I174=0;Prevent PMAC from doing phase search I177=0;Command 0 Direct Current ? I178=0;zero slip in communtation calculations I181=1;Dummy read for Phasing read, Pmac needs something here to continue //Required for BRUSH motor setup I170=0;Cause all values in commutation cycle to be multiplied by zero to disregard commutation vector I196=1;Clears accumilated error from no-existant DC-current loop? I100 = 1 TBQH I'm unfamiliar with the type of output PMAC is providing and what amplifiers I should be using with the Clipper. My biggest confusion is the Output A(JMACH1 Pin 29) DAC1. Looking at the Clipper HRM the DAC1 is produced from a 5V PWM output from a DSPGATE1 and is filtered to make a DAC output. Is it possible for my Clipper PMAC to drive a square wave for a transistor amplifier? From my reading of the manuals and looking at example setups it seems PMAC is meant more for linear amplifiers and I'm trying to fit a square peg in a round hole with using the L298 amp. I've attached the waveform I am getting from the Clipper board. Output A is the top waveform and C is on the bottom. I've attached a small schematic of how I expect the Clipper and amplifier to be connected. Edit: I've had to shrink the picture in order to not break the forum. The top waveforms scale is 5mV and the bottom is 5V. I'm having problems scaling Output A back to 5V. A link to the L298HN datasheet on Jameco. http://www.jameco.com/Jameco/Products/ProdDS/1389249.pdf Thanks for looking. Link to comment Share on other sites More sharing options...
steve.milici Posted April 5, 2012 Share Posted April 5, 2012 Give me a call at my direct line and I will help you with this application: 818-717-5658 Stephen G. Milici Link to comment Share on other sites More sharing options...
Recommended Posts