before I can continue implementing HE current control, I need to set up the model a little better and a little more modularly.
first step is to determine which variables are global:
PWM_period = 75000/PWM_freq_kHz;
Most of the time, I will be using 30kHz, so the PWM period = 2500;
add that to the model workspace.
DNW
Unfortunatly I have had to add PWM_period to the initialisation commands of the masked block. I will do that for the time being while I work out the true function of that block.
WORKS
I have moved the PWM output block out of the other masked subsystem.
WORKS
I now have to change the PWM output so that the inputs to that block are percentage on times.
I have done that so now the inputs should be a number between 0 and 1. In doing that, i removed the need to have PWM_period in the masked initialisation.
duty_cycle_fraction = duty_cycle/100;
POS_off_time = duty_cycle_fraction;
MID_off_time = duty_cycle_fraction/2;
NEG_off_time = 1;
THE MOTOR NOW GOES BACKWARDS DRAWING A LOT OF CURRENT - SOMETHING WRONG!!
problem was NEG_off_time should have been a 0;
DID NOT SOLVE THE PROBLEM - NOT DRAWING HIGH CURRENT BUT NOT TURNING.
check working_masked_openloop.mdl
WORKS
I think that my problem was trying to pass 0.4, and 0.2 as uint16. I have multiplied by 1000 before the pass and divided by 1000 after the pass.
WORKS
Time to change "to memory" and "from memory" to double data type and change the memory location to something better.
I have changed all the data types to "double" removed the x1000, /1000 bit, change the variable names to POS_duty_fraction etc. Also changed the memory locations.
DNW - bummer
check the x1000 bit back in.
DNW
must be those memory locations - change them back to 40,41 and 42
DNW - why did I make so many changes at the same time?
Changed all the data types back to uint16. That was about the only thing left that I changed, other than changing the inititalisation and termination times from neg_off_time to 0.
DNW - draws lots of current and does not move.
I discovered that I had not changed the "from memory" blocks from double to uint16. Now the motor works in a really uneven way.
Maybe I copied one of the orders down wrong.
Here is the correct order
1: MNP
2: PMN
3: PNM
4: NPM
5: NMP
6: MPN
3 was wrong.
WORKS - time for a coffee while I decide which bit to change back first.
I am really keen to get the addresses back to correct, so I will try that first.
I saved to AFM7.mdl just to be safe and changed the addresses of A, B and C to 3F9020, 3F9021 and 3F9022.
WORKS - GOOD!
I saved to AFM8.mdl and tried to change back to "double" data types but the motor does not run smoothly.
Stuff this - back to afm7 and UINT16.
clened up the variables a bit. duty cycle is now defined as 0-1000.
AFM7 is working now so I saved it over AFM8