PDA

View Full Version : HPWM Motor Control



hughgoodbody
- 28th January 2005, 11:38
I am using the two HPWM channels of a PIC 18F452, one to control a motor and one to control a proportional solenoid. The HPWM motor control is new to the circuit. I have been operating the solenoid from HPWM and it works fine. Having just added the motor to the other channel it seems to affect the solenoid.

The motor speed is to change when a pot is adjusted and the solenoid should only adjust by small amounts in relation to a temperature. However as the pot is adjusted, the solenoid seems to open and shut erratically, and it should remain at a constant position. Both motor and solenoid have suitable flyback diodes installed.

Is there any reason for this? Is it a hardware or software problem. I would be most greatful for any insight into this.

hugh

mister_e
- 28th January 2005, 20:53
mmm, could be hardware and software... my assumption is hardware first.

Can you provide any schematics ?!?

Dwayne
- 28th January 2005, 20:59
Hello Hugh,

H>>However as the pot is adjusted, the solenoid seems to open and shut erratically, and it should remain at a constant position. Both motor and solenoid have suitable flyback diodes installed.<<

I agree with Steve... I place my bet on hardware...this pot you are talking about... Can you verify it is a linear pot that is not erratic itself to some degree? Dirt etc will cause erraticness. Can you post a schematic?

Dwayne

hughgoodbody
- 29th January 2005, 11:19
The pot is linear yes. When only one HPWM channel is used, the system works fine ie. as the pot is adjusted the motor speed increases as expected, likewise, if the motor is disconnected the solenoid works fine. But as soon as both are required to function together that is when it messes up.

It seems as though the Duty variable that is being sent to the motor is also being sent to the solenoid, but the solenoid has a completely seperate duty value of its own.

I shall try and post a schematic.

Hugh

hughgoodbody
- 29th January 2005, 13:24
I enclose an attached schematic of the circuit i am using.

Below is some of the code i am using:

The following are the declarations for the set up:

Device 18F452
XTAl = 20

'CCP Module configuration for HPWM
DECLARE CCP1_Pin PortC.2 'HPWM Set up for Channel1
DECLARE CCP2_Pin PortC.1 'HPWM Set up for Channel2

To output the PWM I am using:

HPWM 2, Alpha, 1250
HPWM 1, Bravo, 1250

Where alpha and bravo are declared variables.

I am also using an AD converter on port A, using the FRC oscillator, could this be interfering with the CCP module?

I look forward to hearing any suggestions

mister_e
- 29th January 2005, 21:30
5 volts / 100 ohm= 50ma. Max Io=25ma. What about if you change your resistor to lets say 200-300 ohms? Case you can't change the resistor value, you can insert a buffer between PIC and MOSFET and see if there's any difference.

Can also be caused by a sorta ground loop.

BTW, if you remove all the sourounded stuff (MOSFET, MOTOR,SOLENOID) and monitor your output of the PIC with a scope, do you have great results ?

Can you post your whole code?

obewan
- 30th January 2005, 15:39
As Steve said,increase the 100 ohm resistors to 330 or 470
allso add 22k resistors between gate and ground.

mister_e
- 30th January 2005, 22:41
Is the main supply line and 5 volt stay clean and at the same voltage when motor/solenoid are needed.