Shop OBEX P1 Docs P2 Docs Learn Events
Developments of a Large-Spin-Code into GCC under PropC3 — Parallax Forums

Developments of a Large-Spin-Code into GCC under PropC3

nomadnomad Posts: 276
edited 2013-02-07 21:40 in Propeller 1
hi,
in the moment i working on a Quadcopter with 2 Propeller-Boards:
- 1) PropC3: (with spin)
- LaserRangeFinder
- GPS
- XBEE (1 Module) send Datas to my Laptop
- Intercom (Master) send Datas to PPB
- ev. SD-Card
verry problematic to run not standAllone
Under Spin the stuff running and its ok

- 2) PPB: (with spin)
- RC-6-channel-receiver-interface
- L3G4200D 3-axis gyroscope
- PID-controller
- ESC-output (brushless-ESC) 4 channel
- Intercom (slave) receive datas from C3
under spin the stuff running and its ok

as attachment: c3-quadV2-GXB-05.spin

i have experience with low-level programming with GCC under Linux
(Simple IDE 0.72 or 0.85 unter win7)

now my questions:
- on the C3-board: can i converting this spin-file into GCC ??
- or have this idea no go's ??
- i think the XBEE-Module make some Problems ??

why i do this:
- ev. better performance
- learning

thanks for tips and hints
regards
nomad

Comments

  • RsadeikaRsadeika Posts: 3,837
    edited 2013-02-03 00:22
    A problem that I can see is the lack of drivers written in C. You are using things like a gyroscope, LaserRangeFinder, ..., etc, which I doubt very much that there are C drivers available. You could try using a program called spin2cpp to try too convert these drivers that are written in Spin, in fact, you could try to convert the program that you attached to C using spin2cpp, just to see what happens.

    As a learning process, sure, I would highly recommend it. Just a suggestion though, start out small, in fact, just try to convert one of your module drivers to C first.

    Ray
  • nomadnomad Posts: 276
    edited 2013-02-04 00:52
    hi Rsadeika
    thanks for your answer.
    on Sunday i have make some experiments with spin2cpp-Version 0.100
    gcc-elf is in the SimpleIDE-Version 0.72

    on the powershell i make the convert-step with
    - 1) .\spin2cpp --elf -Os -mxmmc c3-quadV2-GXB-05.spin
    - compile with warnings:

    - on GPS_Str_NMEA_Lite.cpp
    - warnings:
    cast to pointer from integer of different size[-Wint-to-pointer-cast]
    - in the prog its:
    - memcpy( (void *)&(*(uint8_t *)&dat[20]), (void *)C0, 1*(C1));

    - run ok with a.out all *.cpp and *.h - files ok


    - 2) then a second step:
    - loading a.out to PropC3 with usb-Connections with
    - propeller-load.exe with
    - propeller-load -r -t a.out -b eeprom
    - output on power-shell:
    - Propeller Version 1 on COM5
    Loading the serial helper to hub memory
    9528 bytes send
    Verifying RAM... OK
    Loading cache driver 'eeprom_cache.dat'
    1532 bytes sent
    loading program image to flash
    22464 bytes sent
    Loading .xmmkernel
    1720 bytes sent
    [ Entering terminal mode. Type ESC or Control-C to exit. ]
    ading GPS...r LRF module ... :) (icon) ady!

    - this output comes from my program
    - with ESC terminate the programm

    i think for a first experiment, this are good results ???

    a dumb question:
    the last output make me not so happy
    on the c3 gps-Led blink, but the Laser Range Finder - this is "ady" above should be "Ready"
    i think that the program hanging
    what are the next step after propload ok to start my program on the C3
    i think the program is on the EEPROM, should i make a restart or what shoulld i do

    after this, i starting with the PropTool
    -> clearEEPROM.spin then; compile my spin-programm and run on RAM the stuff
    -> all stuff running.

    have you some hints and tricks for me....
    regards nomad
  • ersmithersmith Posts: 6,054
    edited 2013-02-04 11:39
    It might be worth changing the optimization from -Os to -O1 for spin2cpp output. A lot of times Spin code depends on variables being updated by PASM in another COG, which is something that in C requires that the variable be marked "volatile". Unfortunately spin2cpp doesn't do this (it can't figure out what variables are modified by other COGs). Dropping the optimization level down tends to make this problem go away -- at level -O1 things tend to work, whereas sometimes at -Os I get characters dropped on the serial port, just the same problem you reported.

    Eric
  • nomadnomad Posts: 276
    edited 2013-02-04 23:48
    hi ersmith,
    thanks for your answer.
    today i make some experiments with your tips
    thanks and regards
    nomad
  • nomadnomad Posts: 276
    edited 2013-02-05 01:49
    hi eric
    i make some Tests with following optimizations
    1) : -O1:
    .\spin2cpp --elf -O1 -mxmmc c3-quadV2-GXB-05.spin
    - 1) compile:
    - the same warning on GPS_String_NMEA_Lite.cpp
    - a.out is here
    - 2) loading:
    - propeller-load -r -t a.out -b eeprom
    - propeller Version 1 on COM5
    Loading the serial helper to hub memory
    9528 bytes sent
    Verifying RAM ... OK
    loading cache driver 'eeprom_cache.dat'
    1532 bytes sent
    Loading program image to flash
    27544 bytes sent
    Loading .xmmkernel
    1720 bytes sent
    [ Entering terminal mode. Type ESC or Control-C to exit. ]
    - program output:
    Reading GPS...r LRF-module...:) (icon) :) (icon) Ready!

    - hardware results:
    - LaserRangeFinder (Laser) not blinking
    - terminate with ESC OK
    2) : -O:
    .\spin2cpp --elf -O -mxmmc c3-quadV2-GXB-05.spin
    - 1) compile with the warnings

    - 2) propeller-load -r -t a.out -b eeprom
    - output from program
    Reading GPS...r LRF module...:):) (icons)Ready!
    - Terminate with ESC OK
    - but the programm hanging i think so..

    i think the propeller-load make troubles ?
    eventuell wrong -r -t -b ??

    what you are thinking about this failure....

    now i make some research for spin2cpp and prop-load....

    regards
    nomad
  • nomadnomad Posts: 276
    edited 2013-02-06 01:30
    hi eric
    today i make some experiments with spin2cpp and prop-loader:
    after some improvements:

    1) changing the spin-code: works only with LaserRangeFinder + Intercom.
    look at c3-quadV2-GXB-051.spin

    2) spin2cpp: compiling without Opimizations: aka
    .\spin2cpp --elf -mxmmc c3-QuadV2-GXB-051.spin
    - no failure : a.out vorhanden
    - loading:
    - propeller-load -r -t a.out -b eeprom
    - Results:
    - Run Program verry ok
    - some icons, datas correct, laser ok, ESC OK
    - access with pst-terminal ok
    - look at c3-noO-LoadOK-0602-2.jpg

    3) about the icons:
    i think its a failure of the powerShell
    and pst.terminal = pst.Position(n,n)

    i think its good-stuff

    attachments:
    - c3-quadV2-GXB-051.spin
    - c3-noO-LoadOK-0602-2.jpg

    what are thinking about this and
    thanks for your help
    regards
    nomad
  • ersmithersmith Posts: 6,054
    edited 2013-02-06 06:46
    I don't have any of the hardware, so I can't really try this out. As far as I know propeller-load should work OK with -b eeprom, but it's not something I have a lot of experience with. I suspect that propeller-load's terminal emulation is not the same as the PST object expects. Perhaps you could launch your program with propeller-load (without the -t option) and then open up the Propeller Serial Terminal program to read the output. To do this you'll probably want to have a short delay at the beginning to give time to launch PST.

    Eric
  • David BetzDavid Betz Posts: 14,516
    edited 2013-02-06 08:05
    ersmith wrote: »
    I don't have any of the hardware, so I can't really try this out. As far as I know propeller-load should work OK with -b eeprom, but it's not something I have a lot of experience with. I suspect that propeller-load's terminal emulation is not the same as the PST object expects. Perhaps you could launch your program with propeller-load (without the -t option) and then open up the Propeller Serial Terminal program to read the output. To do this you'll probably want to have a short delay at the beginning to give time to launch PST.

    Eric
    The propeller-load "terminal mode" doesn't emulate any escape sequences at all. It is really only good for displaying printf-style debugging information. If you need something more you might try the terminal emulator that is part of SimpleIDE.
  • nomadnomad Posts: 276
    edited 2013-02-07 00:03
    hi
    thanks for your answers :))
    @ eric:
    Thank you, today i work with your [-t....]
    about the results i make a new reply.
    @David Betz:
    i make now some experiments...

    thanks all
    regards
    nomad
  • nomadnomad Posts: 276
    edited 2013-02-07 01:17
    hi all
    thanks for this tip.
    my results proploader: propeller-load -r a.out -b eeprom:

    - 1) propload with new (eric) without -t
    as: propeller-load -r a.out -b eeprom
    - Load-OK
    then starting pst.terminal com5, 115_200 baud
    - results: Verry OK
    - no failure
    - ok

    - 2) experiments david Betz
    - starting ide 0.72 terminal emulations
    - starting ide (starting terminal-emulations on ide:)
    com 5 baud 115_200
    - terminal-output : OK
    - some cryptical icons on every loop
    - hardware are running ok

    please have a look on attachment: propLoad-ide-terminal-1.jpg

    today i make some experiments with all my devices (gps,XBEE)
    regards nomad
    1024 x 569 - 103K
  • jazzedjazzed Posts: 11,803
    edited 2013-02-07 06:26
    Use the most recently published SimpleIDE package:
    https://code.google.com/p/propside/downloads/detail?name=Simple-IDE_0-8-5_setup.zip

    Since you are using windows, the Parallax PST may fit your needs:
    http://www.parallax.com/Portals/0/Downloads/sw/propeller/Parallax-Serial-Terminal.zip
  • nomadnomad Posts: 276
    edited 2013-02-07 21:40
    hi jazzed,
    thanks but i have
    1) SimpleIDE 0.85, 0.72 (0.72 is running)
    2) the propeller-gcc-elf package
    3) pst-terminal

    thanks for the hints
    regards nomad
Sign In or Register to comment.