ViewPort Waiting for Trigger
John Abshier
Posts: 1,116
I cannot get ViewPort to work as an lsa.· I set pin 16 as a rising trigger.· I can see the led on the Prop Demo board flash.· ViewPort says Waiting for trigger.· Here is the smallest code I can make that illustrates the problem.
John Abshier
CON _clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR long parameter
long frame[noparse][[/noparse]400]
OBJ
qs : "QuickSample"
vp : "Conduit"
PUB go | x
parameter := 1000 'a constant here locks to value x percent high
dira[noparse][[/noparse]16]~~
vp.register(qs.sampleINA(@frame,1))
vp.share(@parameter, @parameter)
repeat
!outa[noparse][[/noparse]16]
waitcnt(clkfreq/2 + cnt)
John Abshier

Comments
Did you click on the "lsa" view and choose a timescale? When you're using QuickSample, it takes 10x the horizontal resolution to take the full sample. So, if you're timescale was set to 1sec/div, it'll take 10 seconds before you see anything. I made a slight modification to your program- toggling the led at 1khz instead of 1hz- and included the configuration code which sets up the lsa to view io with a trigger set to pin 16, rising, and timescale set to 1ms. I've attached a screenshot- try it out, you should get the same result... (My screenshot shows an extra tab- the integrated debugger...)
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR long parameter long frame[noparse][[/noparse]400] OBJ qs : "QuickSample" vp : "Conduit" PUB go | x parameter := 1000 'a constant here locks to value x percent high dira[noparse][[/noparse]16]~~ vp.register(qs.sampleINA(@frame,1)) config vp.share(@parameter, @parameter) repeat !outa[noparse][[/noparse]16] waitcnt(clkfreq/2000 + cnt) pub config vp.config(string("var:io(bits=[noparse][[/noparse]16led,30tx,31rx]),v1")) vp.config(string("start:lsa")) vp.config(string("lsa:view=io,trigger=io[noparse][[/noparse]16]r,timescale=1ms"))Hanno
Post Edited (Hanno) : 11/7/2008 3:50:28 AM GMT
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR long parameter long frame[noparse][[/noparse]400] OBJ qs : "QuickSample" vp : "Conduit" PUB go | x parameter := 1000 'a constant here locks to value x percent high dira[noparse][[/noparse]16]~~ vp.register(qs.sampleINA(@frame,1)) config vp.share(@parameter, @parameter) repeat !outa[noparse][[/noparse]16] waitcnt(clkfreq/2 + cnt) pub config vp.config(string("var:io(bits=[noparse][[/noparse]16led,30tx,31rx]),v1")) vp.config(string("start:lsa")) vp.config(string("lsa:view=io,trigger=io[noparse][[/noparse]16]r,timescale=1s"))Start program ViewPort (F10), start ViewPort and connect. Does not work- straight lines for all three variables. Waited much longer than 10 seconds
Stop ViewPort and reconnect. Same as above.
Stop ViewPort and run your program. Connect ViewPort. Works
Stop ViewPort and start program ViewPort. Start ViewPort. Works· But I don't really care about that program.· This program, MotorDriver, is what I am reall intersted in.
''Demonstration of PWM version of NCO/PWM counter mode CON _clkmode = xtal1 + pll8x _xinfreq = 10_000_000 VAR long parameter long frame[noparse][[/noparse]400] OBJ qs : "QuickSample" vp : "Conduit" PUB go | x parameter := 1000 'a constant here locks to value x percent high cognew(@entry, @parameter) vp.register(qs.sampleINA(@frame,1)) config vp.share(@parameter, @parameter) repeat pub config vp.config(string("var:io(bits=[noparse][[/noparse]1f,2r,30tx,31rx]),v1")) vp.config(string("start:lsa")) vp.config(string("lsa:view=io,trigger=io[noparse][[/noparse]1]r,timescale=50us")) DAT 'assembly cog which updates the PWM cycle on APIN 'for audio PWM, fundamental freq which must be out of auditory range (period < 50µS) org entry mov dira, diraval 'set APIN to output mov ctra, ctraval 'establish counter A mode and APIN mov frqa, #1 'set counter to increment 1 each cycle mov time, cnt 'record current time add time, period 'establish next period :loop rdlong value, par 'get an up to date pulse width waitcnt time, period 'wait until next period neg phsa, value 'back up phsa so that it jmp #:loop 'loop for next cycle diraval long 3 'APIN=0 BPIN=0 ctraval long %00101 << 26 + (%000001 << 9)+ 0 'NCO-D/PWM APIN=0 BPIN = 1 period long 4000 '20kHz (50µS period) (_clkfreq / period) time res 1 value res 1Stop ViewPort and start program Motor Driver. Connect ViewPort. Unable to connect Timed Out COM4=No configuration found Prop is on com4
Stop ViewPort and connect again. Unable to connect Timed Out COM1=IO Problem COM4=No configuration found
Exit ViewPort and load it again. Connect. Same error as above.
Exit ViewPort.· Turn off the Prop on Com4. Load MotorDriver program on different Prop on COM11.· Start ViewPort and attempt to connect.· Unable to connect. Timed Out.· COM1=IO Problem COM11=No configuration fount COM4=No configuation found
Went and tried MotorDriver program on different computer.·Unable to connect.
Ok, figured out why QuickSample doesn't work when the horizontal timescale is longer than 20ms/div. ViewPort has a timeout for QuickSample, and will restart the sampling- which explains why you don't see measurements when you use QuickSample at a slow sampling rate. I really never intended QuickSample to be used for slow rates- streaming the data, as opposed to sampling it is easier and a much better experience- try this to get what you originally wanted:
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR long io,parameter 'HANNO share io and parameter OBJ vp : "Conduit" PUB go | x parameter := 1000 'a constant here locks to value x percent high dira[noparse][[/noparse]16]~~ config vp.share(@io, @parameter) 'share 2 longs, don't use quicksample when streaming slow data repeat !outa[noparse][[/noparse]16] io:=ina 'take sample of IO port waitcnt(clkfreq/2 + cnt) pub config vp.config(string("var:io(bits=[noparse][[/noparse]16led,30tx,31rx]),v1")) vp.config(string("start:lsa")) vp.config(string("lsa:view=io,trigger=io[noparse][[/noparse]16]r,timescale=1s"))I got your pwm code working.... My apologies, this issue has been raised before and will be more properly documented and probably fixed soon. Quicksample must run in the first cog! ViewPort stops and restarts this cog remotely to support triggers. If you have something else running in this cog, like your pwm code, it'll get overwritten with quicksample code. It's not trivial to fix, but I'll get around to it- for now, make sure to put the vp.register line first in your programs! See screenshot- it works beautifully! Click on the "edit" button next to "v1" and you can change the duty cycle of the pulse like you intended. Enjoy!
VAR long parameter long frame[noparse][[/noparse]400] OBJ qs : "QuickSample" vp : "Conduit" PUB go | x parameter := 1000 'a constant here locks to value x percent high vp.register(qs.sampleINA(@frame,1)) 'HANNO- QUICKSAMPLE MUST RUN IN FIRST COG! config vp.share(@parameter, @parameter) cognew(@entry, @parameter) repeat pub config vp.config(string("var:io(bits=[noparse][[/noparse]1f,2r,30tx,31rx]),v1")) vp.config(string("start:lsa")) vp.config(string("lsa:view=io,trigger=ior,timescale=50us")) DAT 'assembly cog which updates the PWM cycle on APIN 'for audio PWM, fundamental freq which must be out of auditory range (period < 50µS) org entry mov dira, diraval 'set APIN to output mov ctra, ctraval 'establish counter A mode and APIN mov frqa, #1 'set counter to increment 1 each cycle mov time, cnt 'record current time add time, period 'establish next period :loop rdlong value, par 'get an up to date pulse width waitcnt time, period 'wait until next period neg phsa, value 'back up phsa so that it jmp #:loop 'loop for next cycle diraval long 3 'APIN=0 BPIN=0 ctraval long %00101 << 26 + (%000001 << 9)+ 0 'NCO-D/PWM APIN=0 BPIN = 1 period long 4000 '20kHz (50µS period) (_clkfreq / period) time res 1 value res 1