Shop OBEX P1 Docs P2 Docs Learn Events
Data acquisition problem — Parallax Forums

Data acquisition problem

YannickYannick Posts: 5
edited 2008-09-18 20:39 in Propeller 1
Hi,

I am doing this little project in school: I need to enter a frequency between 1.0 and 100.0 Hz and display the numbers on a LCD with parallel interface. The user needs to be able to erase one number at a time if a mistake is made. The final number (ex: 54.6 ) needs to be stocked in memory and be sent to another application when the user presses another button.

So my question is: what's the best data structure to realize these different operations? Are there objects that already do that or that could help me?

thanks and have a nice day!

Yannick

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2008-09-18 19:19
    hello yannick,

    the best datastructure for realize operation is the type "program"

    yes there are objects for for parallel LCDs

    sending data to another application depends highly on the send-path
    what send-path are you using ?

    Stefan
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-18 19:20
    There are several objects (try "Parallel LCD Driver") in the Propeller Object Exchange that are I/O drivers for LCD displays using the most common display controller (Hitachi). I don't think these objects include any kind of interactive data entry routines. They're mostly for sending one character at a time or a string of characters (or a string of digits representing an integer) to the display. The routines won't handle floating point or a decimal point at all. You'd have to modify them to do what you want. Since all your numbers are values in 1/10's of a Hz, you could just store them as integers and avoid the whole floating point complication. You'd modify the decimal number display routine to insert a decimal point character just before the rightmost digit. There's no particular data structure involved. You're just dealing with an integer value that you're displaying as 1/10's of a Hz.
  • YannickYannick Posts: 5
    edited 2008-09-18 19:46
    Thanks!

    I believe it is a good idea to store each·value as an integer and then add a decimal point character in the display routine.
    The other application to which I need to send the data is a digital potentiometer with a serial interface (I think it's the send-path you meant Stefan). I already have an object to send serial data but they are in the binary format.

    So my next question is: how can I convert the number with each value stored seperately as an integer to a binary format number? I believe I have seen an integer to binary converter somewhere but I'm not sure it would work if every value is stored seperately, especially with the decimal part.

    Thanks again for your help

    Yannick
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-18 19:53
    Since this is a school project, I'll ask you to look up the definition of "integer" and "number", then look up "binary", "decimal", and "base".

    Most of the Propeller display objects (like those for the LCD and for a TV) have a decimal, hexadecimal, and binary display routine. After you look up the definitions I asked, you might try answering your question yourself and consider whether and what these display routines have to do with your digital potentiometer.
  • YannickYannick Posts: 5
    edited 2008-09-18 20:14
    Sorry Mike,

    English is not my first language so maybe I got mix-up with my words. I will ask my question with this example:

    The·resistance I want·is 54.6 ohms, but I store it 546. To send this data to the digital potentiometer, I need to convert it·back to its decimal number display and then to the binary format. Is there an object that can perform this operation?··Maybe I'm wrong but the propeller display objects·like for·TV and LCD convert an integer to binary, not a decimal number to binary.

    I hope I·am a little more clear! Thanks

    Yannick
  • YannickYannick Posts: 5
    edited 2008-09-18 20:25
    Ohh I just found what you meant!

    I think I made a mistake between decimal and float....

    So if I store 546, I need to convert it back to it's Floating-point format (54.6) and then to binary. Is there an object to do that: integer to float to binary?

    Thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-18 20:26
    I'm trying to make sure you understand the concept of number representation, how numeric values are represented inside a computer, how we represent them on paper or an LCD display or TV video display, and how we convert them back and forth when necessary. That's why I want you to look up the mathematical definitions for "number" and "integer" and the idea of a written or display representation.

    I'm not directly answering your question about a conversion object because conversions are not always necessary.

    You might tell us about the digital potentiometer, how data is sent to it, and what the format of that data has to be. You should have a datasheet or other documentation that describes this. Different digital potentiometers do work differently and we need to know the specific requirements.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-18 20:39
    As an example, floating point is literally that ... numbers that include an exponent as part of the number when they're stored inside a computer or other place. Your 54.6 would be represented as 5.46 x 10 (10 to the 1st power) or 546 x 0.1 (10 to the -1 power) or 0.546 x 100 (10 to the 2nd power). Because most computers use a binary representation for numbers, the floating point exponent is usually a binary power (0 for 2 to the 0th power or 1, 1 for 2 to the 1st power or 2, -1 for 2 to the -1 power or 1/2, etc.). Do a websearch for "wiki floating point" and you'll find a better explanation.

    Inside the Propeller, all numbers are normally stored and manipulated in binary form. For external display, to make them humanly useful, we convert them to the equivalent character decimal, hexadecimal or binary form.

    The floating point routines for the Propeller use a standard floating point format described as IEEE 754 32-bit single precision. This is described in detail in one of the Wikipedia articles.
Sign In or Register to comment.