Shop OBEX P1 Docs P2 Docs Learn Events
Does a 'pin' SPIN object exist? — Parallax Forums

Does a 'pin' SPIN object exist?

pedwardpedward Posts: 1,642
edited 2011-11-23 22:20 in Propeller 1
I was thinking about the "problem" I perceive with the Propeller development and thought about making a SPIN object that just does simple pin control.

I did an OBEX search, but no luck. The purpose is to have an object that people familiar with Arduino would take to, then once they actually learn the power of native SPIN, they can use that.

Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-11-23 14:55
    Simple pin control won't require a complex object, just a few lines of code.

    Consider this simple LED control which flashes the LED plugged into P0 on and off.
    CON
      ledpin = 0
    
    PUB main
    dira[ledpin] := 1 'set p0 as output
    
    repeat
      outa[ledpin]:=1 'turn on p0
      waitcnt(clkfreq + cnt) 'wait a moment
      outa[ledpin]:=0 'turn off p0
      waitcnt(clkfreq + cnt) 'wait a moment
    

    More about this can be found at: http://www.gadgetgangster.com/tutorials/372

    OBC
  • pedwardpedward Posts: 1,642
    edited 2011-11-23 15:13
    Jeff, we are on the same page. However, in the Arduino environment they have function calls to set pins.

    I was asking/confirming/proposing this to help newbies to acclimate to Propeller.

    Just to be clear, this isn't a newbie asking a question, I have spent enough time with the Prop to get a grip on it and want to fill in some gaps I see.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-23 15:18
    You might look at the BS2_Functions object in the Object Exchange. This is intended to help with the transition from using a Stamp to using a Propeller and, among other things, provides functions for manipulating the I/O pins like HIGH, IN, and LOW. Other functions include debug stuff, formatted serial I/O, timing input pulses, generating output pulses, doing SPI input and output (clocked shift registers), pauses, etc.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-11-23 15:43
    pedward wrote: »
    ...in the Arduino environment they have function calls to set pins.

    I was asking/confirming/proposing this to help newbies to acclimate to Propeller.....

    Sounds like an excellent idea to me. I'm sure that anything that can help people graduate from the Ardweeno to the Propeller would be a welcome power to possess around here. I'm having worries these days that young acquaintances of mine are going to pressure me into teaching them how to work with Ardweenos, so I'll have to learn how to do that myself, but my inclination, of course, will be to graduate them to Propellers once they get the hang of things.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2011-11-23 16:40
    Sounds like an excellent idea to me. I'm sure that anything that can help people graduate from the Ardweeno to the Propeller would be a welcome power to possess around here. I'm having worries these days that young acquaintances of mine are going to pressure me into teaching them how to work with Ardweenos, so I'll have to learn how to do that myself, but my inclination, of course, will be to graduate them to Propellers once they get the hang of things.

    I don't know if I would so much as "graduate" them as to enable them to understand and evaluate the properties of the propeller in relation to the problem they are attempting to solve. I believe the ardwino remains a single core CPU. The A/D work i have done so far would have taken me a great deal more of time and learning to achieve the same ends had I done it on a single core CPU. I would have also attempted it with my TI dsp devkit for shear speed and availability of some processing functions that are built into the device if not for the propeller chip. If there were one grand unified chip out there (other than Chip of course), we would all be speaking the same code, paying the same price, wearing Mao jackets.. not really on that last one..... but y'all know where I am going.

    I should not say it, but I did wonder if Ardweeno was the gender opposite of Ardweeni.......bad, bad keyboard. whack.... bad keyboard......

    Frank
  • photomankcphotomankc Posts: 943
    edited 2011-11-23 17:26
    Shouldn't be hard to make, so you're looking for some variation of:

    Pins.PinMode(1, Pins#OUTPUT)
    Pins.DigitalWrite(1, Pins#HIGH)

    That should be very simple to accomplish, but the fun part would be, how does the Ardnewbie find said object, or even know to look for it as well as needing to add it in the object section of anything he does? Then there is the fact that learning how to specify the constants and include the object seems no less difficult than leaning:

    dira[1] := 1
    outa[1] := 1

    Maybe I don't see it they way they would. I've gone the opposite direction and taken up playing with Arduino after learning the Prop. I think the multiple registers and need to fiddle with special pin modes makes the libraries on that side an obvious benefit but the simplicity on this side would seem to almost make it more hassle than help.... to me anyway.
  • JonnyMacJonnyMac Posts: 9,198
    edited 2011-11-23 19:29
    In my standard template (attached) I have old-school methods that mimic essential PBASIC functions: PAUSE, HIGH, LOW, INPUT, and TOGGLE.
  • jazzedjazzed Posts: 11,803
    edited 2011-11-23 20:39
    Ever notice how some Arduino code functions borrow from PBASIC names ?
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-11-23 20:57
    Problem is that setting up question/answer for beginners in this format will likely get churned under in forum movement.
    It's a good idea. Why don't you create a Q/A like this and attach it to your .SIG in your profile?

    OBC

    pedward wrote: »
    Jeff, we are on the same page. However, in the Arduino environment they have function calls to set pins.
    I was asking/confirming/proposing this to help newbies to acclimate to Propeller.
  • pedwardpedward Posts: 1,642
    edited 2011-11-23 21:10
    FWIW, I've started making SPIN objects to mimic the Arduino functions. The Arduino SDK is so limited that it really is more about going through the motions than thinking real hard.

    I should have something to show in a little bit.
Sign In or Register to comment.