Shop OBEX P1 Docs P2 Docs Learn Events
End user interface and data input into Propeller MCU — Parallax Forums

End user interface and data input into Propeller MCU

LoopyonionLoopyonion Posts: 24
edited 2013-04-04 13:40 in General Discussion
Hi, Im hoping some knowledgable Propeller users may be able to provide some answers, and guide me in the right direction:)

As a little background on myself, I have a mechanical/electrical engineering past, familiar with very old languages BASIC & MSDOS, newer languages VISUAL BASIC etc, and more importantly, Python from my last six months messing with an arduino "Mega".

I am using the Mega to run some pneumatic solenoids, through FET's, and have hit a point where it was getting messy due to delays, and trying to read sensors whilst delaying actions. And rather than start on interupts etc, came accross information on the Propeller chip.

I have made the decision to go with the Propeller, and also looked into the View Port software, as I need to see what the sensors are reading, and make adjustments accordigly. (Previously, I used arduino sim, not bad at all, but simulation only). I used serial output data to view events, and readings from the Mega.

My question is, how could I produce a system that once I have programmed, can be adjusted by an end user.? I would not want the code altered, just key variables ie timers, and options? I would also need for the end user to visually see on screen the inputs and outputs being created.

I have asked Viewport for an answer, to see if the GUI style development tools would do it, or a cut down version of them is available.

Is serial programming an option? using the serial data stream once configured to output, or input the data required through a windows created program?

Please forgive the number of questions, or my current lack of Spin knowledge.:) , and thanks in advance for any help you can offer!

Comments

  • SRLMSRLM Posts: 5,045
    edited 2013-04-04 01:04
    The easiest way is to use the serial link (via the onboard FTDI chip) to communicate with the Propeller. The Propeller watches the serial link for input commands, and reads/parses those commands. For example (psuedo code):
    global motor_speed
    global COMMAND_1_CHAR = 'M'
    ...
    
    while(true)
        string data = readstringfromSerial()
        if(data[0] == COMMAND_1_CHAR)
             motor_speed = data.split(",")[1]
    

    Then, it would wait for input on the serial like this:
    M,32
    M,33
    M,34
    M,5
    M,2
    M,0
    
    And it changes the motor speed (variable) accordingly.

    The Propeller really excels at this, since you can dedicate a core to watching the serial string for new commands, and still have 7 cores left over for your other tasks (like running the solenoids).

    If you haven't seen it already, I recommend the PropGCC project for a Propeller C/C++ compiler.
    https://code.google.com/p/propgcc/

    Here is a video that I did of something very similar: it uses a Python GUI to interface to the Propeller. In this case, it's only receiving data from the Propeller, but it does have the capabilities to dynamically adjust runtime parameters.
    The python code is available at https://code.google.com/p/anzhelka/
  • LoopyonionLoopyonion Posts: 24
    edited 2013-04-04 01:17
    Thanks:) A good detailed response:)

    So is it possible to store the inputted data from the serial input within the Propeller for use, next time the unit is powered up? ( internal rom etc)..
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2013-04-04 01:49
    I do stuff like this all the time but since I wrote my own Tachyon Forth last year I have been using this exclusively for my projects. I can (as can my clients) load in new code over Bluetooth links and very easily examine and change any variable as well as write short snippets of code to test things on the fly. The other thing is that Tachyon is fast. See my sigs for links if you are interested.

    BTW, welcome to the Propeller forum (which you should be using rather than the General forum)
  • LoopyonionLoopyonion Posts: 24
    edited 2013-04-04 02:08
    I do stuff like this all the time but since I wrote my own Tachyon Forth last year I have been using this exclusively for my projects. I can (as can my clients) load in new code over Bluetooth links and very easily examine and change any variable as well as write short snippets of code to test things on the fly. The other thing is that Tachyon is fast. See my sigs for links if you are interested.

    BTW, welcome to the Propeller forum (which you should be using rather than the General forum)

    Thanks, I will have a look at your links on return from work:)

    Maybe Admin can move this thread to the appropriate section?
  • SRLMSRLM Posts: 5,045
    edited 2013-04-04 02:23
    Loopyonion wrote: »
    Thanks:) A good detailed response:)

    So is it possible to store the inputted data from the serial input within the Propeller for use, next time the unit is powered up? ( internal rom etc)..

    No, the Propeller has to be on. I'd be interested in any MCU that doesn't need to be on to receive data.

    That being said, you could run it at a very low clock speed with a single cog to reduce power consumption, if that's what you're looking for.
  • LoopyonionLoopyonion Posts: 24
    edited 2013-04-04 03:06
    I should of explained myself a little clearer :)

    I understand the MCU cant recieve data when its off :), however, whilst the board is powered, a user can input variables, via the serial data method described above. Then I should be able to make the MCU take that data and store in an address within ROM .

    Then, when the PC is not connected, and the board powered, fetch that data from the ROM to give a variable a value.
  • SRLMSRLM Posts: 5,045
    edited 2013-04-04 13:04
    Loopyonion wrote: »
    I should of explained myself a little clearer :)

    I understand the MCU cant recieve data when its off :), however, whilst the board is powered, a user can input variables, via the serial data method described above. Then I should be able to make the MCU take that data and store in an address within ROM .

    Then, when the PC is not connected, and the board powered, fetch that data from the ROM to give a variable a value.

    Yes, you can save values to the EEPROM that will persist across power cycles. You'll need an I2C driver for that.

    There are two ways that you could do this: "background", and "updateable" (my names):
    Background: Every variable has an address, and this address is the same for the HUB RAM (where it lives when it is on), and the EEPROM (from which the hub ram is copied at startup). You could simply write the updated variable value to the address in EEPROM, and the next time that the Propeller is started it "automatically" pulls the updated variable (as if it had been initialized in the code). Note that variable changes would not persist when you change the code, and it would take some extra logic (simple) to make the new values update live in the hub ram.
    Updateable: For this, you need a 64KB or larger EEPROM (the default in many modern Propeller boards). In this scheme, you store the values in the upper 32KB of EEPROM space at predetermined locations. From there, your code can pull these values into the code and assign their associated variables. These values will persist across code changes.

    I use the updateable method to store things like board number, hardware revision, and file number.
  • LoopyonionLoopyonion Posts: 24
    edited 2013-04-04 13:40
    Nice, so with good code, you could have serial data received by the mcu, then parsed into variables etc, and using some logic look at the stored EEPROM values, then if different, overwrite the EEPROM values.

    Using a little of all the input above, I think it could be achievable.

    Time to get some testing done, and playing with Visual Basic maybe to produce some data streams, and put the Mega up for sale ;)

    Thanks for the help so far ;)
Sign In or Register to comment.