Shop OBEX P1 Docs P2 Docs Learn Events
little project ... — Parallax Forums

little project ...

elecnoobelecnoob Posts: 123
edited 2007-09-16 16:15 in Propeller 1
hi,

it's the first time i want to use the prop. chip so i don't really know the chip, but i programmed already 2 years in vb.net and i also programmed a 8051 but that's in assembly code...
but what i want to do is to make a king of "game console" ...
in this console i want to program 6 games. And 1 of the games is a twister wit 8 in and outputs ..
but now my question is ...
how do i get started the best ...
and can i compare the inputregisters with the output registers?
«13456789

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2007-08-07 10:17
    Hello elecnoob,

    first of all: good thread-start as you write something about your Software-knowlegde.

    you are free to define any of the 32 IO-Pins in any combination as Input or Output.

    So for comparing 8 inputs with 8 outputs you would load the status of the inputs to a variable
    and compare the content of this variable bitwise with a variable that represents the output-state(s)

    Do you think about a game-console with video-output?

    What kind of video-output NTSC-TV-Signal or VGA-Signal?

    Do you want to make very simple grafics like this stoneold "PONG" game or TRYING to coming close to
    Playstation one ?

    (the propeller is pretty good at grafics like the Hydra-games show but it stays at quite some
    distance to Playstations)

    would you like to start at low-cost or is a hydragame starterset not too expesnive?

    after answering this questions it's much easier to say something about how to getting started

    gest regards

    Stefan
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 12:17
    no it's a videogame.
    it's more something hadwareminded.
    to say it easy
    it must be 8 led's that the prop. chip must light up in a radom order
    so you can "remake it" with normal switches
    this is the easy version of the hardware ( the test version")


    "how the "console" must look like"
    later i want to make a bord that stands up ( where the led's are in ) and on the flor squares where you can step on ( switches)..

    tnx stefanL38 for the help
    but can i compare the inputregister with th outputregister?
    because if this is possible
    i can save the binaire code of 1 ledflash" and later if you need to "remake it with the switches" you just compare the inputregister with the output register
    when this is the same you can go on .. when it's not you need to start over.
    or is there an more easy way to do it ?
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-08-07 12:52
    the input register is ina and the output register is outa so you could do:

    if ina == outa
       some code here
    
    



    Graham
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-07 13:08
    I suggest you try working through the Propeller Education Kit tutorials to give you a sense of the basics of this chip. Do you have any kind of development board yet? You can do the tutorials with pretty much anything that has a Propeller in it.
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 13:15
    mike:
    yes i have a propeller proto board
    #32212 and i also have the usb connection to attach to this ..
    these education kit tutorials... aren't they the same as in the datasheet? because i read these ..

    graham:
    i know that you can copare with the if function..
    but i wasn't sure if could compere these 2 registers .. 8051 if i'm not wrong . .has a special register some you can't copare with an other 1 .. so i wasn't sure about this
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-07 13:32
    Yes, the tutorials I'm referring to are the ones mentioned in the datasheet for the Education Kit.

    From the kinds of questions you're asking and your background, I think you should start with the tutorials and actually do them, not just read them. This is a very different sort of animal from an 8051. It's both simpler in some ways and much more complex and rich in other ways.

    If you have the Accessory Kit for the Protoboard, hook up a keyboard and VGA monitor, download FemtoBasic from the Propeller Object Exchange and put it on your Protoboard. It will allow you to "play" with LEDs and switches. It's a simple Basic interpreter rather than Spin, but it has Spin's access to the I/O and all the operators of Spin.
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 13:38
    ok tnx .
    maybe 1 other question . about the comparing of the inputregisters and outpoutregisters..
    can i compare the on byte lvl ?
    are there adresses in where i can referend to .. ?

    but i don't really onderstand the last part of your last post ...
    what is the point of doing that ?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-07 14:02
    Read the Propeller manual's description of INA and OUTA. It has a detailed description and examples of how to access parts of these 32 bit registers in Spin.

    The point of using FemtoBasic is that it's an interpreter that allows access to the I/O pins the same way that Spin does (among other things). You could actually wire up your LEDs and switches (temporarily if you want) and see what it takes to make your algorithm work. You can display debug information on the VGA screen and interact via the keyboard. You can even connect an SD card and load/store/run programs from the card. One of the folks at Parallax used this to make a kiosk to run a variety of demonstration programs.
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 14:15
    ok tnx

    and srry about the ina and outa question . .but it was/ is a part i didn't/don't understand 100%
    bbut i will read it again .. and try to understand ...
    tnx for all this information
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-07 15:49
    elecnob,

    For your random pin function.

    I think this is right... but we'll know for sure when Mike Green agrees[noparse]:)[/noparse]

    i? will set i to a random number

    so x:=i? will set x to the same random number

    x:= ||i? will set x to the absolute value of a random number, i

    i//8 will return the modulus of i divided by 8
    so ||i//8 will return the absolute value of the modulus of i divided by 8 (which is always between 0 and seven)

    so x:= ||i?//8 will return a random number between 0 and 7

    if you have a continuous range of 8 pins...beginning at startpin

    x:=startpin + ||i?//8 will return a what looks like a random pin from your range of pins to the variable x

    Rich
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 17:26
    ok tnx .. but is it possible that you seperate the code from the comment a little better
    because somthimes it's a little complicated
    but tnx

    x:=startpin + ||i?//8 will return a what looks like a random pin from your range of pins to the variable x
    only this i don't really understand ..

    and are you sure that it gives a number from 0 to 7?
    because a random makes the numebers from -214748368 to +2147483647.
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-07 18:29
    elecnoob

    // a remainder operator... so 25//7 returns a 4... the remainder of 25/7... "25 divided by 7 is 3 with a remainder of 4" the result of a // function is always smaller than the number on the right side of the operator. So, if you divide by 8... you will get remainders in the range of zero to seven.

    There is a nice discussion of the absolute value operator, || on page 261 of the manual.
    The random function is actually a little more complicated than I suggested... see page 264
    Unless you want the game to go through the same sequence you have to use the ? function with a variable... that's why I used "i"... you would need to index a value (in this case, i) to give a unique sequence each time... the manual is better at explaining this than anything I can say about it.

    These kinds of expressions are naturally confusing... and then one day... you'll start to believe that there can't be a better way to do it.
    a pseudocode for this expression would be something like:

    X:=i?
    x:=||x
    x:=x//8
    x:=startpin + x

    But Spin let's you put the whole thing together so x:=startpin + ||i?//8
    Spin is case insensitive... so you can write X or x and it means the same thing.

    it works.

    Rich
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 18:55
    ok so for the radom value i only need to put this line
    x:=startpin + ||i?//8

    thank you very mutch ..
    but i still don't understand the startpin thing ( srry )


    for the random number .. there shouldn't be a same order of the number ..
    for example
    1 , 1 , 8 , 6 , 5 =ok
    1 , 8 , 7 , 9 , 3 = ok
    so it really dosn't matter
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-07 19:11
    about the start pin...

    I was assuming that you will be using 8 pins AND that they would be consecutive... so 8 pins from say pin 16 through pin 23. The startpin would be pin 16... so you have that as a constant declaration.

    Con

    startpin=16

    And I think that you want to light up an led connected to one of these pins... chosen randomly.

    You choose a pin... using the above routine.

    I don't understand your third section... but I think you have the right idea.

    Rich
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-07 19:13
    The next step is to write some code... get something working... light up one led... keep it lit until you push a button. There is an example of this in the education kit labs... also in the manual I think.
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 19:14
    ok now i understand the startpin idee ( i already thougt it woul'd be something like that .. but i wasn't sure tongue.gif)
    and my thirtsection ..
    i just wanted to say that numbers may be repeated
    you spoke about a sequence in your previose post .. so that's why i said this
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-07 19:29
    if repeating is a problem... you just store each value in an array... and if the value is already there... look for another... lot's of recent discussion about this topic.

    And then there is the video... you'll need to ask some pretty girls to demo your U-tube invasion.

    Keep us posted.

    Rich
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-07 19:32
    another good place to show what riches a Prop brings to your life: http://hackedgadgets.com/page/1/
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 19:49
    rich:
    the repeat is NOT a problem so i don't need the array
    and i also don't need a video because i'm gone make it only hardware .. with led's and that stuff .. look up in 1 of my other postes tongue.gif

    but i was looking in the manual pg 106
    and i was wondering how i need to put it in a register . .does it save it automaticly in the output register or do i need to save it in the register?

    for lighting a led it would be something like this

    var
    long i
    long x

    con
    startpin = 16

    pub twister

    dira[noparse][[/noparse]16]~~
    x:=startpin + ||i?//8
    !outa[noparse][[/noparse]X]
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-07 19:55
    almost

    x:=startpin + ||i?//8
    dira[noparse][[/noparse]16]~~

    !outa[noparse][[/noparse]X]

    If you want to make the whole thing... you could make 2 and I'd pay for 1... makes it free to you!!!

    I like the video idea.

    Don't you want to be famous?

    Rich
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-07 19:57
    oops... shouldn't be so immediate...

    dira[noparse][[/noparse]startpin]
    ..


    outa[noparse][[/noparse]startpin]

    hope you have the ~~ business straight... have to look it up everytime I use it... I prefer 1's and 0's.

    Rich
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 19:58
    x:=startpin + ||i?//8
    dira[noparse][[/noparse]X ]~~ ==> this is 16 in your post .. but if i say X then it's the number of the random number .. no ?
    !outa[noparse][[/noparse]X]

    and i will think about it ..
    but it's not only a twister that i'm making .. i want to make 5 other games in it to so ..
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-07 20:00
    I wouldn't use it for the game... I just think it would make an interesting wall covering.
    The first thing anyone should do... is try to figure out how to make some bucks out of their hobby...it keeps the significant others under control.
    You could always offload the manufacturing[noparse]:)[/noparse]

    Rich
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 20:00
    rjo_ said...
    oops... shouldn't be so immediate...

    dira[noparse][[/noparse]startpin]
    ..


    outa[noparse][[/noparse]startpin]

    hope you have the ~~ business straight... have to look it up everytime I use it... I prefer 1's and 0's.

    Rich

    the 1 and o's? what is it about ... ?
    because i don't think i read that in the manual..
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 20:05
    before i make some bucks out of it .. i want to get the thing running as i want ..
    and then we will see tongue.giftongue.gif
    but the code .. shoul'd it work with the X ?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-07 20:09
    elecnoob,
    At the risk of being repetitive, a lot of what you're going through is dealt with in the Propeller Education Kit's tutorials. There's also useful information in the "sticky thread" called "Propeller Programming Tutorials, Object Exchange, Tricks and Traps stickies". I would suggest you start with simple stuff, avoid the fancier operators and statements. The advantage of the tutorials is that they already focus on basic concepts and, when you've used those and gotten stuff to work, then you can try fancier stuff to accomplish the same things and go from there.
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-07 20:11
    get your pin assignment into x
    then try
    output[noparse][[/noparse]x]:=1...

    I hate the ~~ because the first time I saw it... I got it backwards... then the next time I saw it... I got it right... then the next time I got it backwards...
    etc. When you get old... memory is like that.

    Rich
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-07 20:14
    AND by the way... I know you know what I meant in one of those earlier posts... but I didn't say it right... so, I'm not even going to try to straighten it out[noparse]:)[/noparse]

    On the video front... one of the ways that you can give PROPer praise to the Parallax team is to go that little extra and bring the Propeller to the attention of other people... a nice video in the right place does that[noparse]:)[/noparse]

    AND you have just the right project!!!
  • elecnoobelecnoob Posts: 123
    edited 2007-08-07 20:27
    but nobody really answered my question
    does the input and output register save on there own or do i need to save it ..
    ( i can't find it in the manual and there are no excerises on )

    tnx mike for the tip... and i will try to do them .. but i need to get this finished before the end of august because then school starts again .. and i don't have that mutch time...
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-07 21:02
    elecnoob,
    What do you mean "save on their own"?

    There's no "saving" involved. That's why there's no description in the manual. The bits of the INA register always give the state of the I/O pins (they're wired that way). Obviously, if a pin is set up as an output using the DIRA register, the input state is the same as the output register state.

    When you set a bit in the OUTA register (and that I/O pin is set up as an output), the I/O pin state becomes what is in the OUTA register bit. The Propeller Block Diagram (in the datasheet and on the website) shows how the output hardware is wired up internally.
Sign In or Register to comment.