Assembly - copy state one's pin to the more pins
How it is possible in assembly copy state one's pin to the more pins?
E.g . (Pin1 , Pin2, Pin3) = Pin1.
Thanks
E.g . (Pin1 , Pin2, Pin3) = Pin1.
Thanks

Comments
mov temp,ina ' Copy INA to a temporary location test temp,#%00010 wz ' Test pin 1 and set Z accordingly muxz outa,#%10100 ' Copy the Z flag to pins 2 and 4You need a temporary location for INA because that's a read-only location and
can't be used in the destination field of an instruction.
'' File: pwm.spin '' Generates a pwm signal. CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR long duty, period, pin byte cog PUB start(ioPin, tHigh, tCycle) : okay {{Start cog and PWM signal ioPin - selects I/O pin for sending the signal tHigh - number of clock ticks high tLow - number of clock ticks low }} pin := ioPin duty := tHigh period := tCycle okay := cog := cognew(@entry, @duty) PUB stop ''Stop cog and PWM signal waitpeq(0, |< pin, 0) dira[noparse][[/noparse]pin] := 0 if cog > 0 cogstop(cog) PUB update(tHigh, tCycle) '' tHigh and tCycle should be in terms of clock ticks duty := tHigh period := tCycle DAT entry movi ctra,#%00100_000 movd ctra,#0 mov addr, par add addr, #8 rdword _pin, addr movs ctra,_pin mov temp, #1 shl temp,_pin or dira,temp mov frqa,#1 mov addr, par add addr, #4 rdlong _cntadd, addr mov cntacc,cnt add cntacc,_cntadd :loop waitcnt cntacc,_cntadd rdlong _duty,par mov temp, par ' add temp, #1 ' rdlong _duty, temp ' neg phsa,_duty jmp #:loop cntacc res 1 _duty res 1 _cntadd res 1 _pin res 1 addr res 1 temp res 1Thanks Lafet
You can't just modify pwm.spin to produce two outputs at the same time since pwm uses the
cog's built-in counters and each counter has only one output of each polarity (if you change to
differential mode which won't help you here). I don't understand why you can't use the same
signal for more than one driver. You'll need drivers (MOSFETs or Bipolar transistors) for the motor
windings anyway. The Propeller can only output about 20ma max from an I/O pin.
How about posting your schematic and some information about the motors?
Propeller 6 signal conductors. 3 for upper side and 3 for lower side H-bridge.
At the same time are excited always one upper and one lower MOSFET. PWM is need
for generate step by step on pin (P0+P5, P0+P4, P4+P2, P3+P2, P3+P1, P1+P5). I
attach flow diagram.
Thank you very much.
if you could write in German please do so
i'm good in englisch and i'm german.
I'm very sorry, but i did not understand at all what you
wrote in the last posting
What kind of motor are you using?
a steppermotor?
if yes
type unipolar or type bipolar?
how many coils does the steppermotor have?
what step-mode do you want to use
fullstep?, halfstep?
if it is another kind of motor
what kind of motor
if you could post the REAL circuit minimum of the 3-Phase MOSFET-Driver and the H-Bridge and Motor
with EVERY SINGLE WIRE would be very great
I'm not sure do you mean you have to switch P0..P5 in the following pattern?
like the table showing the low-high-status of the IO-PIN ?
P0 P1 P2 P3 P4 P5 P6
1.) H L L L H
2.) H L L H L
3.) L H L H L
4.) H L H L L
5.) H L L L H
what is the maximum frequency that you need ?
if you need only some kiloHertz you don't need PWM.SPIN
this could be programmed even in SPIN
so please write something about what this motor is doing in the end
is it only switched on and then running for hours in the same direction at one speed?
does it make a lot of starts and stops and changing the direction?
if you post enough information about your complete project it is much eaysier to find a
REAL GOOD FITTING solution
best regards
Stefan
Sequence:
P5....P0
100001 - step 1
010001 - step 2
010100 - step 3
001100 - step 4
001010 - step 5
100010 - step 6
I need PWM min. 8 kHz, rather but 10 kHz.
I think, that the SPIN be slow, better is Assembly code.
Motor - 42 steps on turn => 7 full sequence.
MOSFET driver - HIP4086:
http://www.intersil.com/cda/deviceinfo/0,1477,HIP4086,00.html#data
Need all-purpose controller to 20000 rpm. I don't know, how much will starts and changes directions.
I don't have circuit diagram, I use basic connection.
Thank you very much, Lafet
this should be very easy in assembly-code
at the moment i have not much time
so i gave you just a short description of the principle
that's just loading one of six 6-bit pattern to the OUTA-Register
waiting some time and then load the next 6bit-pattern
to get an all-purpose 0-20.000 rpm controller the waiting-time
should be variable
this could be done by a HUB-RAM-variable
you have one cog with a SPIN-Program to change rotationspeed=waiting-time
this SPIN-Prg launches a second cog with an assemblerdriver
in the coginitstatement you have to pass the adress of this HUB-RAM-variable to the ASM-Prg
in the ASM-Prg you can read HUB-RAM with the rdlong-command
the ASM-Prg is switching the bitpattern from step 1 to step 2 ... step 6 and then starts again with
the bitpattern for step 1
so this is just a few mov-, waitcnt-, jmp-commands in assembly-code
you could start with the LED-blink example from the manual
the manual example toggle one bit by using the xor-command
you have to use the MUXZ-command for changing Bit P0..P5 of the OUTA-register
this as first tips how you can solve it
maybe the next few days i have time (in the evening) to write some example-code
best regards
Stefan
I would have thought the PWM should be ANDed with the phase sequence so it acts like a DC motor with variable voltage input. The commutation is like the brushes, the PWM like the voltage supply.
If you try to just change the times between the phases that will not do the same thing. Your suggestion Stefan is more like driving it as a stepper motor but varying the pulse frequency.
Lafet,
It seems the best thing would be to spend some time studying assembly on the propeller.
Graham
By the regulation BLDC motors is need adjust PWM and commutation. PWM adjusts mean value voltage on winding. Change driving sequence is dependent on information from magnetic sensor (position rotor). I need have on two pins at the same time PWM. I would like use modification object file "PWM.SPIN", only I need copy state APIN from register CTRA into two pins according to the mask driving sequence.
:loop waitcnt cntacc,_cntadd rdlong _duty,par mov temp, par ' add temp, #1 ' rdlong _duty, temp ' neg phsa,_duty *** here copy state APIN to the 2 other pins *** jmp #:loopLafet
Instead produce it directly using assembly and waitcnt.
Have a look at this thread:
http://forums.parallax.com/showthread.php?p=647408
Step 3 happens to show some code for PWM. Step 2 describes bitmasks.
Graham
does this mean you REALLY need PWM = variying ON/OFF-Time of the signal?
AND changing the frequency?
the waitcnt-command in assembly works the following way
you setup the "waiting" initially
DAT {Toggle P16 5 cycles} mov Time, cnt 'store actual value of counter in "variable" called Time add Time, #9 'add a minimum of 9 (Cycles) to this value because the counter goes on counting up while 'the add-command and the waitcnt-command is beeing exectuted 'and the value of var Time must be still AHEAD of the actual countervalue. 'otherwise the waitcnt-command will wait for 53 Seconds until he reaches again this value '= counter will count to maxvalue=2^32 turn to 0 and count up to the value :loop waitcnt Time, Delay 'now this waitcnt-command waits until the counter reaches the value of variable "Time" 'then the value of variable Delay is ADDED to variable Time 'this means at the next waitcnt-command the Prop will wait until the counter will reach the value 'of variable Time. Which was already setup at the last waitcnt-command ! 'this make it possible to do a different amount of commands inside a loop, that have a different runtime 'but the START of next loop will be exact after the SAME timedifference (comming from the "variable" Delay) xor outa, Pin djnz Cycles, #:loop Pin long |< 16 Delay long 15_000_000 Cycles long 10 Time res 1in this example changing the ON/OFF-Time inside one Cycle is not included
for changing ON/OFF-Time you have to use two waitcnt-command like in the example 3 datatransfer.spin
from graham in his thread
http://forums.parallax.com/forums/default.aspx?f=25&m=187621
do you know the details how the commutation must be changed depending on the feedbacksensor?
best regarrds
Stefan
If you have three hall sensors these can almost act like the brushes of a DC motor, they determine the commutation (change from one state to the next) while the PWM determines the power in and will change the speed of the motor which will then increase the commutation speed automatically. Of course with sensorless control you use the back EMF to provide the commutation info. So rather than driving the rate at which the state changes you alter the power in the states and let the motor itself increase the state change rate, clear as mud?
I was looking at making an electric unicyle, I was considering making a big brushless disk motor myself to which I would attach a normal encoder with an index pulse. That would allow me to essentially treat the motor as a DC motor, the control from the tilt sensor would just control the PWM and direction and another cog would control the commutation based on the encoder. Easy to say but more work to do!
Graham