 |
|
 |
| Parallax Forums > Public Forums > Propeller Chip > Book for absolute beginners. Propeller 101 | Forum Quick Jump
|
 |  Harprit Registered Member

       Date Joined Dec 2008 Total Posts : 62 | Posted 12/14/2008 6:41 PM (GMT -8) |   | I do believe you are right However, It runs, I just ran it. Let me check it over gain and get back with you all because it works!!
Harprit | | Back to Top | | |
 |  Harprit Registered Member

       Date Joined Dec 2008 Total Posts : 62 | Posted 12/14/2008 7:28 PM (GMT -8) |   | Well Tharkun, old buddy, old pal,
Turns out you got fooled and then you fooled me! The "Initialize LCD" line is not a heading it is a subroutine call and it is not tabbed back like you quoted it. This subroutine used to be further down the program about 10 lines and I moved it up as "better practice" I should also confess that I make minor improvements as I go along like the fact that in program 4 the cursor no longer blinks! This is because we no longer need to see it. When you first start out and clear the LCD you can't tell it you did any good because there is no cursor. You might be just hung up some place so a blinking cursor is needed to reinforce your first success.
So the rule it that you have to go over the entire program and find subtleties every time! Sorry! I will try to call these out as we go along so the newbies are not lost in the woods.
Program 5 is having 3.3 vs 5.0 volt problems that I have to get a simple fix for before I post it. Soon. It investigate what the signal that runs a R/C servo looks like by measuring both the up and the down signal width. We will then use this pulse to put out half this pulse width so that the servo moves only 90 degrees instead of the usual 180 degrees end to end. This can be described as a simple signal processing task! No very high brow but, we can do signal processing with a Propeller now
Even so, Thank You for a very careful reading and Thanks You for responding I hope you will respond regularly. Every bit helps (Pun intended)
Harprit | | Back to Top | | |
   |  Harprit Registered Member

       Date Joined Dec 2008 Total Posts : 62 | Posted 12/15/2008 1:09 PM (GMT -8) |   | Thank you Tharkun
I would have never found it. Now to put the code back into the program and get it finished Soon
Harprit | | Back to Top | | |
 |  Andy Lindsay (Parallax) Forum Moderator

       Date Joined Jul 2004 Total Posts : 1095 | Posted 12/15/2008 1:36 PM (GMT -8) |   | On line 195, you need to calculate the result of clkfreq/1000 before multiplying it by your delay time. When the result exceeds 2^31, you end up subtracting instead of adding the delay value to the cnt register in the waitcnt command. 107*20M is positive, but 108 x 20M is negative. If you instead divide clkfreq by 1000 first before multiplying it by your ms delay value, your ms pause times could be much larger than 107. (Max ~26.8k)
By convention, Parallax does not use the name start for a method unless it is a library file that is designed to launch a cog based on the parameters it receives. If a library object instead does work in the same cog, use config or init, but not start. When naming a method at the beginning of a top file, we typically use a name like go, or something that describes what the method is doing.
Education Department
Parallax, Inc. Post Edited (Andy Lindsay (Parallax)) : 12/16/2008 7:39:14 PM GMT | | Back to Top | | |
   |  mikediv Registered Member
        Date Joined Dec 2007 Total Posts : 455 | Posted 12/16/2008 12:29 PM (GMT -8) |   | | Harpit thank you for your effort I am trying to devour every single thing I can get on the prop I am new as well and every effort is very much appreciated | | Back to Top | | |
 |  Andy Lindsay (Parallax) Forum Moderator

       Date Joined Jul 2004 Total Posts : 1095 | Posted 12/16/2008 1:45 PM (GMT -8) |   | | Harprit,
Adjustments to the name of the top file's first method and clock configuration constants look good.
A note on your PAUSE method. clkfreq returns the number of clock ticks in 1 second. If you want a result in milliseconds, divide clkfreq by 1000 in your waitcnt commands.
See I/O and Timing Lab, pages 7 through 11 for more information. Full PDF download is in the Propeller Education section on the www.parallax.com/Propeller -> Downloads page. Reference information on the waitcnt command is also available on pages 175-176 in the Propeller Manual, which is also up for full PDF download from the Propeller Downloads page. Andy
Andy Lindsay
Education Department
Parallax, Inc. Post Edited (Andy Lindsay (Parallax)) : 12/16/2008 10:58:08 PM GMT | | Back to Top | | |
      |  Harprit Registered Member

       Date Joined Dec 2008 Total Posts : 62 | Posted 12/19/2008 10:59 AM (GMT -8) |   | Mike
I used a very generic 16x2 LCD with the Hitachi controller built in Got mine at AllElectronics ($6 LCD117) but they have a minimum on shipping. There are many other sellers. Get one with the pins in one line, the rest is not so important.
For the rest of the readers, the next program runs a DC motor with three cogs.
Harprit | | Back to Top | | |
 |  Harprit Registered Member

       Date Joined Dec 2008 Total Posts : 62 | Posted 12/19/2008 12:20 PM (GMT -8) |   | Folks, Help!!
I am having trouble with a segment of code designed to create a very simple PWM signal that is easy to understand
The total cycle is 255 time frames long So turn on for 255-PWM and turn it off for PWM for a constant cycle length of 255 PWM is in Beta Here is the code, unfortunately the tabs are suppressed
PUB COG_THREE(alpha, beta) dira[alpha]~~ outa[alpha]~~ repeat outa[alpha] :=0 UTIL.PAUSE(45) '<change is in this line outa[(alpha)] :=1 UTIL.PAUSE(255-beta)
The above code works but 45 needs to have a variable here Here is the code again
PUB COG_THREE(alpha, beta) dira[alpha]~~ outa[alpha]~~ repeat outa[alpha] :=0 UTIL.PAUSE(beta) '<change is in this line outa[(alpha)] :=1 UTIL.PAUSE(255-beta)
this does not work It works with a number where 45 is but fails if I put in the variable beta
Harprit | | Back to Top | | |
 |  Andy Lindsay (Parallax) Forum Moderator

       Date Joined Jul 2004 Total Posts : 1095 | Posted 12/19/2008 2:33 PM (GMT -8) |   | It's hard to say without seeing the code.
You might be asking the cog for more stack space when you switch from a constant to a variable, so one possible problem could be that the number of elements in the stack array for the cog is no longer sufficient. Try increasing the number of elements in the stack array. Also, check to make sure each cog gets a different portion of the stack array (if you have one long stack array). Or, just declare a different stack array for each cog. Either way works.
I usually like to declare a large number for each stack array, and then trim out down as a final step. 40 is a pretty safe number that you are not likely to exceed unless you have a lot of nested methods, calculations, large arrays, etc. For more info, see the "How Much Stack Space for a Method Launched into a Cog?" section in the Methods and Cogs Propeller Education Kit Lab for a write up on rough stack length calculations. Also, Project 2 in the Objects lab uses the Stack Length object from the Propeller Library to test an object to find out how many elements a cog uses in a stack array.
SIDE NOTE: For Spin, cognew should always be in the same object as the method it launches. Never try to use cognew to launch a method that lives in a different object.
Andy Lindsay
Education Department
Parallax, Inc. Post Edited (Andy Lindsay (Parallax)) : 12/19/2008 11:01:32 PM GMT | | Back to Top | | |
 |  Harprit Registered Member

       Date Joined Dec 2008 Total Posts : 62 | Posted 12/19/2008 3:01 PM (GMT -8) |   | Andy this is really weird
This does not works
repeat ' outa[alpha1] :=0 PAUSE(beta) outa[(alpha1)] :=1 PAUSE(255-beta)
this works
repeat ' outa[alpha1] :=0 PAUSE(255-beta) outa[(alpha1)] :=1 PAUSE(beta)
It is not sensitive to the stack space allocated The pause commands are just reversed in location but they are not changed.
Harprit | | Back to Top | | |
  |  mikediv Registered Member
        Date Joined Dec 2007 Total Posts : 455 | Posted 12/21/2008 6:43 PM (GMT -8) |   | | | |
  |  Harprit Registered Member

       Date Joined Dec 2008 Total Posts : 62 | Posted 12/22/2008 5:13 AM (GMT -8) |   | I'll see what I can do on schematics. These programs are pretty simple and the connections are obvious from the code, but yes schematics are nice. It takes time to do them and I have only so much time to do this but I think your request is totally legit so I need to do them. I will put one out late today.
Thanks for getting on me about it. Like all of us, I need a kick now and then.
Harprit. | | Back to Top | | |
  | 93 posts in this thread. Viewing Page : 1 2 3 4 | | Forum Information | Currently it is Saturday, November 21, 2009 11:30 AM (GMT -8) There are a total of 393,855 posts in 55,536 threads. In the last 3 days there were 84 new threads and 706 reply posts. View Active Threads
| | Who's Online | This forum has 17692 registered members. Please welcome our newest member, old guy. 66 Guest(s), 14 Registered Member(s) are currently online. Details heater, Siri, Kenny Gardner, keith_kw, Jay Kickliter, mctrivia, Alsowolfman, Shawn Lowe, dMajo, Harprit, Rick Brooks, Beau Schwabe (Parallax), Leon, MicroDirk |
Forum powered by dotNetBB v2.42EC SP2.02 dotNetBB © 2000-2009 |
|
|