Parallax Forums
  HomeLog InRegisterCommunity CalendarSearch the ForumHelp
   
Parallax Forums > Public Forums > Propeller Chip > Book for absolute beginners. Propeller 101  Forum Quick Jump
 
New Topic Post Reply Printable Version
93 posts in this thread.
Viewing Page :
 1  2  3  4 
[ << Previous Thread | Next Thread >> ] | Show Newest Post First ]

Tharkun
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2008
Total Posts : 6
 
   Posted 12/14/2008 3:49 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Harprit said...
Here is program 4.


HSS


Hi Harprit,
very nice examples !
But I think there is a small mistake in program4:

INITIALIZE_LCD                               'sets up the parameters that we want on the LCD
  DIRA[DataBit7..DataBit0] := %1111_1111       'the lines that control the LCD are outputs             
  DIRA[RegSelect] := 1                         'the lines that control the LCD are outputs
  DIRA[ReadWrite] := 1                         'the lines that control the LCD are outputs
  DIRA[Enable]    := 1


The LCD-INITIALIZING must set after the DIRA-commands like in program 2 and 3 !!??

Stay tuned !
(I'm waiting for program5) cool
Back to Top
 

Harprit
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/14/2008 6:41 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/14/2008 7:28 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/15/2008 12:07 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Program 5 is delayed

Here is the problem

Here is what I think is a bug in the SPIN software
I came across this while trying to write a high pulse
So I converted it to a pulse to an LED
I eliminated all the rest of the code so there is no confusion
This is what I sent to Parallax
See if you can discover anything more


I think I have a bug to report
Take a look at the attached program
All you need is an LED on line 23 to run it an see the bug hang thing up.

Lines 91 and 94 are or interest. If the variable is 107 or less it works
If it is 108 or more it gets stuck at line 91 and fails/hangs up

Could you please try this and get back to me.

Harprit

File Attachment :
ProgramTest.spin   12KB (application/octet-stream)
This file has been downloaded 58 time(s).
Back to Top
 

Tharkun
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Feb 2008
Total Posts : 6
 
   Posted 12/15/2008 12:42 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Hi Harprit


_clkmode = xtal1 + pll8x
  _clkfreq = 20_000_000


160Mhz is a little bit fast for the prop !


Tharkun

Post Edited (Tharkun) : 12/15/2008 8:50:06 PM GMT

Back to Top
 

Harprit
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/15/2008 1:09 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1095
 
   Posted 12/15/2008 1:36 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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.
 
For lots of examples of this, see the Propeller Education Kit Labs.


Andy Lindsay
Education Department
Parallax, Inc.

Post Edited (Andy Lindsay (Parallax)) : 12/16/2008 7:39:14 PM GMT

Back to Top
 

Invent-O-Doc
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2007
Total Posts : 47
 
   Posted 12/16/2008 11:21 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Try to keep the examples as concise as possible. Beginners will do better with several small examples to perform each task followed by one that integrates several. Also, a beginning text would do well to discussing variables, reading data in code and string operations. Good luck!


----------------------------------------
Thomas Talbot, MD
Gunpowder, MD, USA

Back to Top
 

Harprit
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/16/2008 12:00 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
MD:

Will see if we cant work towards that.
The programs are short, the rest is mostly LCD support which I will move.
Thanks for the feedback.

All:

Here is program 5
3 pics
I used a PIC based programmable signal generator I made as the
radio signal substitute so not to pollute the airwaves.
Documentation is in the program so I will not repeat it here
A lot more discussion will be in the book, I have not written it yet.

Harprit
Image Attachment :
Image Preview
IMG_0162.JPG
  1.07Mb (image/jpeg)
This image has been viewed 128 time(s).
Image Attachment :
Image Preview
IMG_0163.JPG
  838KB (image/jpeg)
This image has been viewed 86 time(s).
Image Attachment :
Image Preview
IMG_0164.JPG
  799KB (image/jpeg)
This image has been viewed 94 time(s).

File Attachment :
Program5.spin   14KB (application/octet-stream)
This file has been downloaded 76 time(s).
Back to Top
 

mikediv
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2007
Total Posts : 455
 
   Posted 12/16/2008 12:29 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1095
 
   Posted 12/16/2008 1:45 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/16/2008 2:11 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Mike:

Thanks for the feedback. Ive got a lot more coming for us beginners
Keep me posted. I need feedback.

Andy:

Thanks for keeping an eye on our progress. We need someone with some
experience to look over our shoulders. I try to follow what I get from you.
Please keep an eye on this site an keep your comments coming. I need
them.

All.

Sorry about the quality on Pic2 and Pic3. Here is Pic3 again but I already
took down the set up so I cant do Pic2 again. Pic1 pretty much covers the
same area.

HSS
Image Attachment :
Image Preview
IMG_0166.JPG
  712KB (image/jpeg)
This image has been viewed 96 time(s).
Back to Top
 

Harprit
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/17/2008 7:25 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
While writing the next program that has to do with using 2 cogs I ran into the
need to refer to Methods located outside the programs. This has not been
explained so I am submitting a program that shows how to do this

This is Program6 which is exactly the same a Program5 with the Methods
that serve the LCD moved off to an OBJECT called "LCD Routines"

You need to study this program before you study program 7 which uses
two COGS in an introductory format. I will post it next

Programs
Program6 and LCDRoutines are attached
Load and Save them to the same file

Harprit

File Attachment :
LCDRoutines.spin   8KB (application/octet-stream)
This file has been downloaded 73 time(s).

File Attachment :
Program6.spin   6KB (application/octet-stream)
This file has been downloaded 66 time(s).
Back to Top
 

Harprit
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/18/2008 6:54 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Program 7

Runs two simple cogs at the same time

If you can not understand what is going on please report what it is
because this is critical to moving to the next level.

The next program will make the cogs talk to one another

Utilities OBJ is also attached. It contains some fo the Methods used.

Harprit

File Attachment :
Program7.spin   5KB (application/octet-stream)
This file has been downloaded 68 time(s).

File Attachment :
Utilities.spin   1KB (application/octet-stream)
This file has been downloaded 64 time(s).
Back to Top
 

Harprit
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/18/2008 8:18 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Program 8
Attached

Demonstrates ease of displaying on one COG what is happening in the other


Harprit

File Attachment :
Program8.spin   5KB (application/octet-stream)
This file has been downloaded 75 time(s).
Back to Top
 

mikediv
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2007
Total Posts : 455
 
   Posted 12/19/2008 10:06 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Harpit if you get a chance can you tell me wich LCD you are using is it from Parallax I want to get the same one so I can use your interfacing schematic
 
Back to Top
 

Harprit
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/19/2008 10:59 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/19/2008 12:20 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 1095
 
   Posted 12/19/2008 2:33 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/19/2008 3:01 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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
 

Harprit
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/21/2008 2:08 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Here is program 9

This program allows you to control the speed of a DC motor in one direction
from a hobby R/C servo signal.

3 COGs undertake three different tasks. I did not pass any variable through
the COGS but rather used the general CON and VARs.

Program 10 will add reversibility.

I had a hard time coming up with the PWM routine.
I wanted a very simple one that was easy to understand
The waitcnt command is not suitable as I discovered after a lot of time input
Counters are too complicated for now. Did not want to use tricky commands

Photos also show the amplifier and motor I used.
Use listing to see where to connect what on the PROPELLER

Harprit
Image Attachment :
Image Preview
IMG_0173.JPG
  750KB (image/jpeg)
This image has been viewed 72 time(s).
Image Attachment :
Image Preview
IMG_0174.JPG
  976KB (image/jpeg)
This image has been viewed 72 time(s).

File Attachment :
Program9.spin   6KB (application/octet-stream)
This file has been downloaded 67 time(s).

File Attachment :
LCDRoutines.spin   9KB (application/octet-stream)
This file has been downloaded 47 time(s).

File Attachment :
Utilities.spin   1KB (application/octet-stream)
This file has been downloaded 41 time(s).
Back to Top
 

mikediv
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2007
Total Posts : 455
 
   Posted 12/21/2008 6:43 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
as always very cool thank you
Back to Top
 

statemachine
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2005
Total Posts : 24
 
   Posted 12/21/2008 8:21 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
  You need schematics,Harprit.Do you have the prop font?
Back to Top
 

Harprit
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/22/2008 5:13 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
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
 

Harprit
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Dec 2008
Total Posts : 62
 
   Posted 12/22/2008 7:24 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Program 9A
Same a 9 but with schematics

Schematics will be provided with all future programs per request from StateMachine

Thanks to all for feedback.
Here you see the benefit!

Program 10 will add reversing to the motor, in progress

Harprit

File Attachment :
Program9.spin   20KB (application/octet-stream)
This file has been downloaded 66 time(s).
Back to Top
 
[ << Previous Thread | Next Thread >> ]
New Topic Post Reply Printable Version
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