Shop OBEX P1 Docs P2 Docs Learn Events
PINK V2 object for spin stamp — Parallax Forums

PINK V2 object for spin stamp

Peter VerkaikPeter Verkaik Posts: 3,956
edited 2007-12-21 02:47 in Propeller 1
I converted my PinkV2 javelin class to a spin object.
Both are attached so they can be compared. The spin object compiles without error.
I have a few questions:

Is it possible to pass a FullDuplexSerial object to the PinkV2 object?
Right now, I pass the tx pin and rx pin but I rather define the uart
in my main program.

The methods writeVarBuf and readVarBuf have a parameter buf.
This is supposed to be a byte array holding a null terminated string.
I hardcoded the length of this buffer to 64 bytes, but is it possible
to extract the bufferlength from the parameter itself (eg. buf.length)
or must I pass the length using an additional parameter?

In java, method overloading allows me to use the same method name
with different parameter lists. The method writeVarString does the same
as writeVarBuf, except it has a string as parameter.
Does this at all apply to spin, or is a string in spin just a byte array?
(in which case writeVarString can be omitted)

Is it possible to define public and private constants?
The public constants would be used to address the special pink registers by name.

regards peter

Post Edited (Peter Verkaik) : 12/11/2007 4:26:44 AM GMT

Comments

  • DgswanerDgswaner Posts: 795
    edited 2007-12-11 04:39
    thank you thank you thank you. I'm getting my pink back any day and that was the first thing I needed to do when I got it. now to figure out the serial communication between RF modules! did I mention, THANKS!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-11 06:08
    Here is my test program for the PinkV2 object.
    It compiles but some things need to be addressed.

    I defined two methods debug and printf that output a string and formatted string
    to a serial outpin. Since my testprogram is intended for the Spin stamp
    I would like to use the SOUT pin. What pin number is SOUT?

    I copied the Pink constants to the main program. Is there a way to reference
    these constants (defined in PinkV2 object) directly other than copying
    from the object.

    Also, can anyone answer the questions in my previous post?

    regards peter
  • Harrison.Harrison. Posts: 484
    edited 2007-12-11 06:24
    To answer some of your questions:

    Is it possible to pass a FullDuplexSerial object to the PinkV2 object?
    - You cannot pass objects via pointers or anything of the sort. You can use SerialMirror, which is a FullDuplexSerial implementation that allows sharing of a serial port across multiple objects. You can get this object from the object exchange.

    must I pass the length using an additional parameter?
    - The array concept is not like the one provided in Java. There is no .length operator since arrays in SPIN are just a group of consecutive memory locations. You will have to use a constant define or pass lengths for array bounding. If your array is guaranteed to be a zero terminated string than you can use strsize() to obtain the current length of the string contained in the array.

    In java, method overloading allows me to use the same method name with different parameter lists. .... Does this at all apply to spin, or is a string in spin just a byte array?
    - You cannot use method/function overloading in SPIN. The compiler will give you an error such as 'symbol already defined'. You will have to have different function names. Also, a string is just a byte array that is zero-terminated. You will be passing pointers to strings.

    Is it possible to define public and private constants?
    All constants are private to the specific object/source file. They can be externally accessed by myObj#myConstant.

    Is there a way to reference these constants (defined in PinkV2 object) directly other than copying from the object.
    You access constants by using myObj#myConstant.

    Harrison

    Post Edited (Harrison.) : 12/11/2007 6:30:11 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-11 06:37
    Thanks.

    How do I reference spin stamp pins SIN and SOUT? I have read in this thread
    http://forums.parallax.com/showthread.php?p=671535

    that SOUT may or may not work. I would like to test this for myself.

    regards peter
  • Harrison.Harrison. Posts: 484
    edited 2007-12-11 06:43
    You would reference them just like any other IO pin. The actual pins used can be located in the Spin Stamp documentation schematic (last page): parallax.com/Portals/0/Downloads/docs/prod/prop/SS1-IC-v1.0.pdf
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-11 12:26
    Here is an updated Pink V2 test program.
    I added pin definitions for SOUT, SIN and ATN of the spin stamp.
    Also completed the debugOut method.

    Edit: since strings are just null terminated byte arrays,
    I removed the writeVarString method and renamed writeVarBuf and readVarBuf
    to writeVar and readVar.

    regards peter

    Post Edited (Peter Verkaik) : 12/11/2007 2:01:25 PM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-14 10:18
    Updated version.
    Used buf[noparse][[/noparse]h] where I should have used byte[noparse][[/noparse]buf+h] to access bytes.
    Also used >= instead of =>

    regards peter
  • DgswanerDgswaner Posts: 795
    edited 2007-12-14 17:50
    I'll give this a try tonight if not over the weekend. I was too excited about my new HB25's to get to my pink! I'm excited to try it out!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-14 19:29
    Let us know your results. It does work on the javelin.
    I won't be able to hook it up to the spin stamp
    until I got my new board (with fixed Pink connector) assembled.
    That won't be sooner than next week, awaiting parts.

    regards peter
  • DgswanerDgswaner Posts: 795
    edited 2007-12-17 06:54
    "fixed Pink connector" is there a special connector needed for connecting the pink to the propeller? I though you could just connect it to any of the I/o pins. I'm hesitant to try this with out knowing for sure.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-17 10:36
    Perhaps I should have used "dedicated".
    On the picture it is the 2x5 pinheader that connects directly to
    the Pink 2x5 header using a flatcable.
    You only need the connections TX,RX,GND,5V as in the documentation.

    regards peter
    1280 x 960 - 304K
  • DgswanerDgswaner Posts: 795
    edited 2007-12-17 15:15
    I looked though the docs and couldn't see any special connector so I said what the heck and just tried it. I couldn't get it to work. I'm pretty sure that it's a communication problem. I'll have to look at it in more depth when I get home from work. have you tried it from a propeller to a Pink? I'm 99% sure I have every thing connected correctly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-17 15:20
    Not yet. Probably wednesday or thursday.

    regards peter
  • DgswanerDgswaner Posts: 795
    edited 2007-12-18 15:31
    Still no go, I'm interested to see how it works out for you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-19 22:30
    Attached are a new version of the PinkV2 object and a test program (for spin stamp).
    As the picture shows, the code works for me.

    regards peter
  • DgswanerDgswaner Posts: 795
    edited 2007-12-20 15:07
    I've got to be missing something simple here. The most recent code tries to work better but I still can't get it working. I don't have a separate debug connection, I'm working on that. so I'm using programming connection (30,31) for debug. I added a 6 second delay to the start to give me time to change the com port setting on the Stamp debug window. The program is executing and I'm getting info in the debug window but it's just a mess of characters. from what I can tell from the code it's just timing out because if I look at the PINK variable config page, none of the variables are getting changed. If I connect my basic stamp to my pink it will work, I've tried a sample program to send text to the debug window and it works fine. usually when you get info but it's garbled it's a baud rate setting (in my experience). I've double checked the settings and just to be sure I used every baud mode 0-3 for the full duplex object.
    your multicogdebug object references a format object, is that the format object from the object exchange? that's what I've been using. Am I missing some thing? I'm connecting the TX/RX lines directly to the propeller i/o pins on the propeller. What am I doing wrong?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-20 15:25
    To use pins 30 and 31, just set debugPort to 1.
    You then must get readable text using 9600 baud, 8 databits, no parity.
    I do so.
    If you do not use a spin stamp, change the clocksettings appropiate.
    Propeller demoboard
    · _clkmode = xtal1+pll16x
    · _xinfreq = 5_000_000

    Because debugPort is set to 1, the monitor ATN pin (in seperate cog) is not started.
    (I only included it to be able to reset the spin stamp via the ATN pin).

    Lets tackle this step by step. First you must get readable output.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-20 15:34
    And yes, the Format and MultiCogSerialDebug are also in the object exchange.
    I attached them here also for convenience.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-20 15:44
    Note that the pink has TTL (5V) signals. So put a 1k resistor in series
    with the TX and RX pin of the pink. That's how I connected the pink
    to pins A10 (via 1k to pink TX) and A11 (via 1k to pink RX).
    Also note that the pink requires 250mA+ current. I have a seperate
    power supply for the pink.

    regards peter
  • DgswanerDgswaner Posts: 795
    edited 2007-12-20 15:58
    I'll try that as soon as I get home from work. I thought about changing the clock setting but I wasn't sure what I was doing. I'm using a Proto board, I love the flexibility you built in with the debug window.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner
  • DgswanerDgswaner Posts: 795
    edited 2007-12-21 02:47
    Success!!! all I had to do was change the clock setting and I was good to go! now lets see if I can pull off some actual programing! This is for my PINK Base Station. Controlling a bot via the web. bi-directional communication will be via some RF modules! to a Prop on the other end!

    Thanks this is a huge mile stone.

    I added some 1k resistors! it did work with out them... but I know it's tempting Merphys law

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner

    Post Edited (Dgswaner) : 12/21/2007 2:53:31 AM GMT
Sign In or Register to comment.