Shop OBEX P1 Docs P2 Docs Learn Events
More help understanding cogs and including other SPIN files in program. — Parallax Forums

More help understanding cogs and including other SPIN files in program.

eagletalontimeagletalontim Posts: 1,399
edited 2009-10-31 19:30 in Propeller 1
Basically, I need to have a cog that will run one code all the time which will update a variable on my main function. I am a little confused on the stacks and stuff like that for each cog.

I am also trying to understand how adding a pre existing SPIN file to my program works. Do i just add it to my list in the top left of the screen and call each function in my main program? I tried to figure that part out on my own, but that did not work too well.

Last but not least, I was wondering if the Propeller can take a preset variable, lets say variable Mytrims, and save it to the EEPROM that is used for the program. Each time the propeller boots up, the variable "Mytrims" will be loaded based on the last amount it was set at in the previous run time.

Example :

First start up (default value):
Mytrims := 1
The variable is changed to Mytrims := 6 during run time and then the car is shut off.

Next boot : Mytrims := 6 (pulled from EEPROM as last saved value)
Same senario as #1


EDIT : One more thing......

When running a single Red, 7 segment display, is it necessary to use resistors from the pins since the voltage from the Propeller is much lower than the SX? Is so, what size do I need?

Post Edited (eagletalontim) : 10/31/2009 1:11:55 PM GMT

Comments

  • LeonLeon Posts: 7,620
    edited 2009-10-31 13:35
    You need resistors to limit the current. Use Ohm's Law to calculate the value, depending on the current you want to put through the segments.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-31 14:23
    Hello eagletalontim,

    you have to be more soecific in your description if others should understand what you mean.
    "Do i just add it to my list in the top left of the screen..."

    I guess you mean the propellertool. But in the top left of the screen I have a white space. In the middle I have subfolders and middledown left files are listed
    But that's it not. Are you using the latest version of the propellertool V1.2.6 ? Did you take a look into the PE-Kit Lab ?
    see attached picture

    It doesn't matter which board you have. With all kinds of propeller-boards like Protoboard, PPDB, Demoboard, PropRPM, or Propstick
    with all of them you can work through the PE-Kit Lab. Start reading there. If you have questions just post them here in the forum.
    Depending on the board you use you have to set up small hardware like an LED with current-limiting resistor
    a button with pull-down-resistor. But then everything works.

    You wrote that you made a try to use another spin-file.
    create a zip-archiv from your spin-files and attach them to a posting see attached picture

    I recommend to learn some basics about objects and cogs and then start looking into I2C.drivers to store values in the EEPROM

    best regards

    Stefan
  • tronsnavytronsnavy Posts: 70
    edited 2009-10-31 15:50
    Strongly recommend you purchase the "Propeller Education Kit Labs: Fundamentals" book (or at least download, see link).· This book is indispensable wrt the basics.· You will learn a lot about passing variables among objects.· You will also learn the power of the counter.· This underutilized tool is amazing.· Good idea to have a hard copy.· I refer to it all the time.· Good luck.
    http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/PELabsFunBook-v1.1.pdf
  • eagletalontimeagletalontim Posts: 1,399
    edited 2009-10-31 16:33
    I was able to use some code I found in the forum and modify it to save my variables to the eeprom when needed. At boot up, they are retrieved and loaded back into the same variable name [noparse]:)[/noparse] Now, I have to figure out how to read engine RPM. Since the propeller does not have a PULSIN command, I guess I will have to take a different approach. If anyone has any ideas or commands that I should look into, please let me know.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-31 17:42
    Hello eagletalontim,

    maybe I'm wrong. I got the impression that you are working "quick & dirty" and ask for very basic things that are "homework"

    So my hint is only:

    search through the object exchange. Don't know what it is ? Go googling and find out

    best regards

    Stefan
  • eagletalontimeagletalontim Posts: 1,399
    edited 2009-10-31 18:54
    thanks for letting me know about the object exchange [noparse]:)[/noparse] I have it bookmarked now. I was able to find the BS2 functions in there and it looks as though I can use that.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-31 18:58
    I recommend doing another search in the obex with keywords related to rpm
  • eagletalontimeagletalontim Posts: 1,399
    edited 2009-10-31 19:04
    I did search for rpm and this is the only thing it showed :

    "Written in Asm this LED Sequencer in one cog is also usable as an I/O controller or simple logic pattern generator. Suitable for such projects as animated displays and simple control systems. Demo works with either Demo board or PropRPM."

    I tried engine, tach, square wave and nothing matched what I need.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-31 19:30
    OK,

    You did a search (your "homework") and I will add some more points.

    "learning how to fish": if very close related words don't give a hit. Try more fare away related words like "frequency", "pulselength", "sensor"
    and use PARTS of words like "freq" which gives more hits. Be inspired by the hits about NEW words that you did not think of.

    here you can get the search-result of search-word "freq"

    Of course I'm in advantage as I do a almost daily look into the obex what is new uploaded and download almost everything. So I know there are some other objects.
    Therefore I use a pre-defined bookmark that sorts all entries by columm published descending. So I see always the newest objects on top

    http://obex.parallax.com/objects/?o=0&ot=dsc

    best regards

    Stefan
Sign In or Register to comment.