how to use the sine table. example please.
Something simple like draw a sine wave on a graph if you will.
an x and a y.
one full wave. all positive(easy prop math) length like 1024 and highth like 2048. (mr. prop has got enough numbers, is a height/amplatue of 8192 or 16384 easier?). so basicly 1024 coordinates. that i can save/use somewhere to make a graph. something simple to learn from. thanks
can someone do it?? the highest math i've ever taken was algerbra 1. (sucky childhood)
i'm trying to learn sin/cos but its a bit nutty for me. i get the triangle bits, but how to apply or effectivly use the functions, i haven't. but i don't really have the time. its hard enough finding time to play electronics or watch the news.
thanks :-)
an x and a y.
one full wave. all positive(easy prop math) length like 1024 and highth like 2048. (mr. prop has got enough numbers, is a height/amplatue of 8192 or 16384 easier?). so basicly 1024 coordinates. that i can save/use somewhere to make a graph. something simple to learn from. thanks
can someone do it?? the highest math i've ever taken was algerbra 1. (sucky childhood)
i'm trying to learn sin/cos but its a bit nutty for me. i get the triangle bits, but how to apply or effectivly use the functions, i haven't. but i don't really have the time. its hard enough finding time to play electronics or watch the news.
thanks :-)
Comments
One of the best applications I can think of is to generate real sine waves. You need three waves that are 120 degrees apart to drive 3 phase brushless motors (like the ones used in CD players and R/C airplanes)
byteloose: they are (i think) really useful. not just for signal generation but for other stuffs, liiiike that might involve something moving in a circle(or similar), or triangle stuff(like finding location). what exactly however i'm not sure :-) i'm still grass-hoppa :-)
i imagen its..... like on my mill i have two rotarty tables. most people are like why?!?! i'm like so i can cut this fancey cut without haveing to use a cnc controller :-) and they are like wooah you can do that? never would have though that could do that.... hecne why i wish they would add more to that 'PE kit labs' sticky thread!!!!! (finish up the prop1 education before prop 2 so when prop 2 comes i'll be able to understand all the new stuff)
Speed controllers for brushless motors are exclusively PWM devices, of course.
{{ }} CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 'scale255 = 16_777_216 OBJ pst : "Parallax Serial Terminal" 'knob: "knob-sensor" VAR LONG clkf 'WORD 'BYTE pinnum PUB sinedump | loopvar, loopcount, tmp, address waitcnt(clkfreq*3 +cnt) outa[16..23]~ dira[16..23]~~ 'dira[0..7]~~ '~ phsb := 0 frqb := 0 phsa := 0 frqa := 0 clkf := clkfreq pst.Start(115_200) 'start the serial terminal pst.Clear pst.Str(String("starting ed")) 'pst.Dec(tmp) pst.NewLine repeat loopvar from 0 to 4096 step 2 ''the sine table, as shown in the prop datasheet. address := $e000 + loopvar '' is a set of 2048 words (1 word = 2 bytes, so 0 to 65000 ) tmp := word[address] '' it is stored at memory address (hex) $e000 to $f001 pst.dec(tmp) ''note 2048 words = 4096 BYTES . $f000 + $f001 = the last word of the dataset pst.NewLine 'the step 2 is because we are reading words and not bytes 'fyi you can take a address add add to it.. (hex) $e000 + 2 = (hex) $e002 (the next word) waitcnt(clkf/100 + cnt) 'also the data is very fine/indept/high resoultion.... SoOoOoo ' what if you want more speed or what ever and don't care for high resoultions ' just change the "step 2" to step 8.... ' 4096 / 2 = 2048..... 8 / 2 = 4 ' 2048 / 4 = 512 ... alot fewer the 2048 but still MORE than enough data points
pretty basic way of displaying the sine table.but most important is its a lesson on how to access it and make it do something
{{ }} CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 'scale255 = 16_777_216 OBJ pst : "Parallax Serial Terminal" 'knob: "knob-sensor" VAR LONG clkf 'WORD 'BYTE pinnum PUB sinedump | loopvar, loopcount, tmp, address, smarttimemath, smarttime waitcnt(clkfreq*3 +cnt) outa[16..23]~ dira[16..23]~~ dira[0]~~ '..7]~~ '~ phsb := 0 frqb := 0 phsa := 0 frqa := 0 clkf := clkfreq pst.Start(115_200) 'start the serial terminal pst.Clear pst.Str(String("starting ed")) 'pst.Dec(tmp) pst.NewLine ctra[30..26] := %00110 'duty mode ctra[5..0] := 0 smarttimemath := clkf / 7000 '120 why wasn't that 120 hz? smarttime := cnt repeat repeat loopvar from 0 to 4096 step 12 address := $e000 + loopvar tmp := word[address] 'reads sine table data stuff if loopcount == 1 tmp := -(tmp) 'pst.dec(tmp) 'quick explaination of my mathmatical shinangains.... 'pst.NewLine 'the sine tabel is from 0 to 65_000 (and has 2048 entreies) tmp := (tmp * 32_768) + 2_147_483_648 'the duty counter works from 0 to (2^32)-1 aka 4_294_967_295 frqa := tmp 'i think, i should check that ' smarttime := smarttime + smarttimemath 'the sine table only covers one QUARTER of the wave waitcnt(smarttime) 'so we have to take the max table valuve and times it by 'x to make it half the max duty number repeat loopvar from 4096 to 0 step 12 '65_536 * x = (4_294_967_295 / 2) ... x = 32_768 'there now we can make the sine table more duty counter address := $e000 + loopvar 'friendly. why half that (2^32)-1 number? tmp := word[address] 'because the sine table is one quarter of the wave and i if loopcount == 1 'want to make a whole wave. right now we've kinda got half tmp := -(tmp) ' so take the sine table number times it by 32_768 'and we've got 0 - 2_147_483_648 aka half of the duty counter tmp := (tmp * 32_768) + 2_147_483_648 'if you didn't get it, thats good for half a sine wave frqa := tmp 'now for top and bottom 'take sine table data times it by 32_768 and add that 2bil smarttime := smarttime + smarttimemath 'number and you'll have the top quarter of the sinewave waitcnt(smarttime) 'now pull the sine table data BACKWARDS, count down if you 'will. and now you've got the whole top of the wave if loopcount == 1 ' 1.66 volts to 3.3 volts loopcount := -1 'now to get the bottom. 'make the sine table data negitive. before you add the 2 number loopcount++ 'sine data = -0 to -2bil ... + 2bil changes it to ' 2bil to 0 aka the bottom of mr duty counter
http://www.tcee.biz/oldrandomstuffkeepallways/sinewave.jpg if the forum tool didn't workneat-o... that completes today's lesson,
now to go fix my brokewagon ( bet you didn't know volks was german for broke, they had you tricked to uh? to bad america won't build a diesel 50mpg car)
Thanks very much for making this post. I had spent several hours trying to get code from other posts to work and this worked the first time!
Steve