Shop OBEX P1 Docs P2 Docs Learn Events
Trying to get a picoplc compiled spin program to work with Quickstart — Parallax Forums

Trying to get a picoplc compiled spin program to work with Quickstart

skylightskylight Posts: 1,915
edited 2012-12-19 18:36 in Propeller 1
Hi there, I have generated a spin file through picoplc and am trying to light up a led on the quickstart. The spin file is attached and I wondered if someone would be kind enough to look it over, as far as i'm concerned the quickstart should be lighting up one of the leds for approx 5 seconds but I am having no luck lighting up any leds.

the con statement uses 22 which should be one of the leds (P22) or am I confused about the pins/ports?

timerled.spin

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-12-18 08:09
    For a start ... nowhere in the generated code is an I/O pin set to output mode (DIRA bit set to 1). The system clock frequency is specified as 4MHz with a PLL multiplier of 16. That means that the crystal frequency is 250KHz. That won't work since the PLL is specified to require an input frequency from 4MHz to 8MHz.
  • skylightskylight Posts: 1,915
    edited 2012-12-18 09:02
    Thanks for replying Mike,
    I'm now wondering whether picoplc is compatible with the quickstart, the ladder side works fine in simulation it seems that the generated spin code is at fault.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-12-18 09:26
    The QuickStart board isn't special. The question is whether picoPLC works at all with the Propeller. These errors are pretty fundamental and would cause failure with all Propeller boards.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-12-18 10:24
    I changed the clocking so it was correct and changed DIRA to $00FF_0000 so it could output to the LEDs and it turned the LED on for a second and then turned it off. No blinking. The code generation is certainly in question.
  • AribaAriba Posts: 2,690
    edited 2012-12-18 10:39
    mindrobots wrote: »
    I changed the clocking so it was correct and changed DIRA to $00FF_0000 so it could output to the LEDs and it turned the LED on for a second and then turned it off. No blinking. The code generation is certainly in question.

    I think that's why you don't find it anymore on the Net, only on some Prop-users harddisks.

    PicoPLC was a fork of LDmicro which seems to work well, but has no direct Prop support. But LDmicro allows to output an "Interpretable bytecode". I have once made an interpreter in Spin for that bytecode, which also had some extensions.
    If there is enough interest I will search it on my harddisk, maybe I can also add the QuickStart buttons as logic inputs.

    This ladder logic questions come every half year here in the forum, but the interest is normally net very high.

    Link to LDmicro: http://cq.cx/ladder.pl

    Andy
  • skylightskylight Posts: 1,915
    edited 2012-12-18 23:35
    It did seem too good to be true, Thanks all for investigating, @Ariba I would be interested if you were to add compatibility with the quickstart. Unfortunately I'm a novice at the spin code so a lot of it is over my head, but i'm trying to learn as much as I can and all these examples help a lot so please if you can spare the time do continue it's much obliged. Any alternative to programming the propellor is a bonus as people like myself can understand Ladder logic and Basic as in femtobasic and seeing the generated spin code will help with understanding spin more as I can build more and more complex examples and see how spin copes with it.It also helps me to build programs for the prop that I otherwise would find impossible to do in spin.
    Many thanks with all your help with this.
    skylight
  • StefanL38StefanL38 Posts: 2,292
    edited 2012-12-19 03:53
    Hi skylight,

    almost any spincode can run on any propeller-board. Expessially just sensing inputs for high/low and switching outputs on/off
    will work with any propeller-chip-board
    or

    will not work with any propeller-chip-board

    commands like
    DirA[5] := 1
    OutA[5] := 0

    etc. etc. will work exactly the same way on any board.
    Differences in behaviour may come from additional hardware like resistors that are soldered on the board or connected in an other way

    I took a look into the schematic of the quickstart-board. nothing connected to IO-Pins 8-15
    LEDs connected on pin 16-23,
    Touchpads and resistors on pin 0-7
    USB-to-serial-interfacechip on IO-pins 30,31 and EEPROM on 28,29

    This means IO-Pins 8-15 are completely free and work exactly the same way as IO-pins on a PPDB, Protoboard, propboard-USB, propstick USB, Propeller-board of Education.
    toggling IO-pins 8-15 with the LEDs will make the LED blink.

    Again any differences in behaviour will come from hardware that has a fixed connection to IO-pins like LEDs or DAC-resistors.

    As I wrote in the general forum thread picoPLC creates two bugs
    attached to this posting there is the corrected picoPLC-code to make LED on P17 blink endlessly and the correlating picoPLC-file

    Edit: oldest programmers wisdom I've ever heard:

    Your code does ALWAYS EXACTLY what you have coded.
    If your code does something else than you expected it to do
    you don't exactly understand what you have coded.

    for ARM-processors etc. there are several bugs in th processor itself.
    So for those processors there are certain exceptions that confirm the rules.

    Inside the propeller-chip since 2006 when the propeller-chip was born not a single bug inside the propellerchip was found.
    The only thing that was ever found is a high special usage of a PASM-command
    that has not a bug but a somehow unexpected behaviour which was well explained by Chip Gracey himself
    so the behaviour of the propeller-chip is completely predictable and regularly.

    best regards
    Stefan
  • JordanCClarkJordanCClark Posts: 198
    edited 2012-12-19 04:58
    StefanL38 wrote: »

    Your code does ALWAYS EXACTLY what you have coded.
    If your code does something else than you expected it to do
    you don't exactly understand what you have coded.

    I learned it as "Your code does what you tell it to do, not what you want it to do"...:lol:
  • kwinnkwinn Posts: 8,697
    edited 2012-12-19 18:36
    I learned it as "Your code does what you tell it to do, not what you want it to do"...:lol:

    Same here! Most frustrating. I would much prefer if it was the other way around.
Sign In or Register to comment.