Exact match. Not showing close matches.
PICList
Thread
'[SX] SX48 PWM Problem'
2007\07\12@081109
by
djh82ukn/a
|
|
Heya Guys
I tried the example from the help file on PWM, and I get the an erro saying TrisB is not defined. Any Ideas?
[Quoting: "Somebody"]
' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
'
' Uses PWM through an RC network to create an analog voltage.' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ 4_000_000
ID "PWM"
' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------
DAC VAR RB.0 ' output to RC network
' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
angle VAR Byte
duty VAR Byte tmpB1 VAR Byte
tmpB2 VAR Byte
' =========================================================================
PROGRAM Start
' =========================================================================
' -------------------------------------------------------------------------
' Subroutine Declarations
' -------------------------------------------------------------------------
SIN SUB 1 ' returns sine of angle
COS SUB 1 ' returns cosine of angle
' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------
Start:
DO
FOR angle = 0 TO 255 ' sweep through angles
duty = SIN angle ' get sine of angel
duty = duty + 127 ' bias to 2.5 v
PWM DAC, duty, 1 ' charge RC network
NEXT
LOOP
' -------------------------------------------------------------------------
' Subroutine Code
' -------------------------------------------------------------------------
' Use: value = SIN angle
' -- "value" returned as signed byte (-127 to 127)
' -- angle is expressed in Brads (0 - 255)
SIN:
tmpB1 = __PARAM1 ' get angle
tmpB2 = tmpB1 ' make copy
IF tmpB2.6 = 1 THEN ' in 2nd or 4th quadrant?
tmpB1 = 0 - tmpB1 ' yes, move to 1st/3rd
ENDIF
tmpB1.7 = 0 ' reduce to 1st quadrant
READ SineTable + tmpB1, tmpB1 ' read sine
IF tmpB2.7 = 1 THEN ' was angle in 3rd/4th?
tmpB1 = 0 - tmpB1 ' yes, adjust
ENDIF
RETURN tmpB1
' -------------------------------------------------------------------------
' Use: value = COS angle
' -- "value" returned as signed byte (-127 to 127)
' -- angle is expressed in Brads (0 - 255)
COS:
tmpB1 = __PARAM1 + $40 ' get angle (adjust phase)
tmpB1 = SIN tmpB1 ' call sine table
RETURN tmpB1
' =========================================================================
' User Data
' =========================================================================
SineTable:
DATA 000, 003, 006, 009, 012, 016, 019, 022
DATA 025, 028, 031, 034, 037, 040, 043, 046
DATA 049, 051, 054, 057, 060, 063, 065, 068
DATA 071, 073, 076, 078, 081, 083, 085, 088
DATA 090, 092, 094, 096, 098, 100, 102, 104
DATA 106, 107, 109, 111, 112, 113, 115, 116
DATA 117, 118, 120, 121, 122, 122, 123, 124
DATA 125, 125, 126, 126, 126, 127, 127, 127
DATA 127
|
|
It's TRIS_B
Bean.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201633
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\12@122045 by djh82ukn/a
|
|
Sorry I typed it from memory (not good)
it still does not mentions tris_b in the example from the manual however
Anyone advise?
Sorry to be a pain
Thanks
DJH
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201677
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\12@123124 by Sparks-R-Funn/a
|
|
I copied what you posted and it compiled without errors for me. What version of SX/B are you using? You can find the latest version in a "sticky post" at the top of this forum.
- Sparks
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201679
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
|
|
heya
Newest version, downloaded 2 days ago :(
Got it working now, was a bug with the ide, copied the code, restarted pasted and it worked.
Now I cannot get it to simply dim an led now :(
regardless of duty being 10 or 250, led is same brightness, is any extra circuitry required? as with the picaxe, you just use an led, and a resistor.
DJH
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201714
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\12@163339 by PJ Allenn/a
|
|
Is the LED connected to RB.0?
You have: PWM DAC, duty, 1>
RB.0 will PWM for 1ms. That's not long enough to see anything. Are you figuring it's going to stay at the charged voltage so that you can base your brightness on it? That won't work like that.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201723
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\13@073048 by djh82ukn/a
|
|
Ah sorry i stole that code from the pwm example.
I did try just pwm with a duty between 1 and 255 and the duration as 1000 the led comes on but thats it no variance in brightness, always the same brightness regardless of duty.
Also can this not be done with just a reisitor and led as on the picaxe series of chips (basically a pic chip with a bootloader)
Thanks
DJH
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201810
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
|
|
DJH,
You need to create the simplest program that demonstrates the problem.
If you just want PWM then there is no reason that "PWM pin, value, duration" won't work. value and duration must be from 0 to 255. This is all right in the help file. Duration cannot be 1000.
Bean.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201828
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\13@094611 by djh82ukn/a
|
|
ah crap. good point bean thank you
I spent so long messing with it that I forgot about that, I did also try it with 100
Will try it again
DJH
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201854
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\13@095052 by djh82ukn/a
|
|
ok this has the same problem led just stays on (obviously this is not all the code, the rest is just declarations)
Start:
DO
FOR duty = 0 TO 255 ' sweep through angles
PWM DAC, duty, 250 ' charge RC network
NEXT
LOOP
Nobody has said if i can even do this with just an led and a resistor?
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201857
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\13@101056 by PJ Allenn/a
|
|
OK -- Yes, all you need is a resistor and an LED.
This program works (the LED starts OFF and then gradually increases to full ON), I am watching it right before me --
DEVICE sx28, oschs3, TURBO, OPTIONX
IRC_CAL IRC_SLOW
FREQ 75_000_000
PROGRAM Start
duty var byte
TRIS_A = $00
Start:
DO
FOR duty = 0 TO 255 ' sweep through angles
PWM RA.0, duty, 50 >speed of change
NEXT
LOOP
I am using RA.0 for the output, and I am not using a capacitor or RC network at all (and I don't know why you are.)
You will have to change the FREQ directive to match your time-base.
|
|
Okay I forgot to mention. Make the program as simple as possible. But then post the ENTIRE program. There are many things you could have wrong in the parts you haven't posted.
You got to help us help you...
Bean.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201865
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\13@111755 by djh82ukn/a
|
|
Thanks guys been a hard day, Im not using a cap or RC network, those comments were left over from the code taken from the manual.
I am now trying this code but I just get a "Tris_a not defined" error.
[Quoting: "Somebody"]
DEVICE sx48, OSC4MHZ
IRC_CAL IRC_SLOW
FREQ 4_000_000
PROGRAM Start duty var byte
TRIS_A = $00
Start:
DO
FOR duty = 0 TO 255 ' sweep through angles
PWM RA.0, duty, 50 ' charge RC network
NEXT
LOOP
2007\07\13@112235 by djh82ukn/a
|
|
hmm when it tries to compile it opens a *.src file and says that tris_a is not defined and it highlights a line in the assembly, if i just delete that line it works :S
[Quoting: "Somebody"]
MOV FSR,#__TRISA
Any ideas why this would happen? Sorry Ive been getting used to the propeller, but need to use the SX for it's larger number of outputs and cheaper price.
Thanks
DJH
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201876
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
|
|
Okay, now we are getting somewhere ! The missing piece of the puzzle is that you are using the SX48.
This can be corrected by adding a line: __TRISA CON __TRIS
I will make sure this is corrected in the next release of the compiler.
Thanks,
Bean.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201882
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\13@130025 by djh82ukn/a
|
|
woohoo my inadequencies as a programmer came in helpful? :smile:
Thanks for all of your help also, i do not mean to be a pain, once I pick things up I will bother you all a bit less :)
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201902
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\13@130554 by djh82ukn/a
|
|
hmm if I try to program the below code with or without the TrisA = nothing happens, no error box pops up as usual or anything, just "SX/B Error" in the bottom of the application.
[Quoting: "Somebody"]
DEVICE sx48, OSC4MHZ
IRC_CAL IRC_SLOW
FREQ 4_000_000
PROGRAM Start duty var byte
cntr var byte
__TRISA CON __TRIS
'TRIS_A = $00
Start:
duty = 255
DO
FOR cntr = 0 TO 255 ' sweep through angles
duty = duty - 1
PWM RA, duty, 50 ' charge RC network
NEXT
low ra.0
pause 10000
LOOP
|
|
You have not specifed a pin for PWM. You have RA which is a whole port.
Bean.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m201912
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\14@143136 by jesse_in_venicen/a
|
|
i've been using the r/c network in the example, w/ both a 1uf cap & .1 ufd cap (& changing the charge time from 10 to 1..). both configurations w/ a 10K resistor.. What I've addad is a 2n7000 series J-mosfet on the output & the hold time is outragous !!! I can send a single PWM instruction & the circuit will hold the val for many MINUTES.. not secs or millsec's..
in trying to cut down code space, however, I've hit a snag... I need to be able to specify the PIN in the PWM command as a variable... I'm sending pulses out each RA & RB port bit ( 16 seperate PWM commands..yuk) & want to use a generic 'send' subroutine, passing pin & duration as params... any ideas??
thanks,
jesse in venice..
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m202051
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\16@171059 by James Newtonn/a
|
|
Just a quick note to say how impressed I am with Bean for his work on the SX/B compiler and with Parallax for sponsoring it. People who program in BASIC rather than ASM or C really owe you guys a debt of gratitude. Same day help with programming, bug report and fix, and quick turns on compiler versions are sadly lacking in this industry.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m202442
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
2007\07\16@172248 by djh82ukn/a
|
|
I did not realise Bean works on the SX/B Compiler
Thank you, would never have tried out the SX chips without it :)
DJH
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=201629#m202445
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)
More... (looser matching)
- Last day of these posts
- In 2007
, 2008 only
- Today
- New search...