Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re: variable/constant input from a PC ?

2004-07-14 by Robert Adsett

At 07:13 PM 7/14/04 +0000, you wrote:
>--- In AVR-Chat@yahoogroups.com, Robert Adsett <subscriptions@a...>
>wrote:
> > The longer answer (you knew there was a longer answer) is you need
>to write
> > something at the microcontroller end to have a 'conversation' over
>the
> > serial port to get the new values and store them somewhere (EE
> > maybe?).  The microcontroller would parse an input string of
>something like
> > this
> >
> > a 100
> >
> > which it would interpret as setting value a to 100.  It would then
>sore
> > that somewhere for the control program in the micro to read.
>
>
>Makes sense.
>
>If I have 10 timing loops and want each to be indivudually set, I can
>declare a constant for each
>
>a = 100  ; seconds
>b = 900
>c = 60
>  and so on
>
>then input a string of
>
>a 100 b 900 c 60 (and so on) so that these would be altered in the
>program and used for the timing counts.
>
>I know the format is not correct, but the idea is that I would
>probaly have to send all the values each time, or maybe just the ones
>I want to change.  (guess this is that trees in the forest thing)

Depends on how you write the parser.  But something like that.

Maybe something like

switch( cmd) {
     case 'a':
           store_timer( 1, value);
           break;

     case 'b':
           store_timer( 1, value);
           break;

       :
       :

      case 'z':
           dump_data();
           break;

      default:
           print_serial( "Unknown Command\r\n");
            break;

      }

The details of parsing the input to get cmd and value are left as an 
exercise ;)

Your main program would do something like:

acquire_data()
{
recall_timers();
run_data_schedule();
}

One of the keys here (especially at the beginning) is to strictly limit the 
level of complexity you will accept, realize there will be things you 
cannot do (especially in your first rev) and use it as a learning 
experience to figure out what works and what doesn't.  Sometimes what 
appears to be awkward to begin with works well enough that there is no real 
desire to change it.  For example you may find it is simpler to gather 
everything at the same rate and simple ignore the extra data later.  Serial 
data chips are not terribly expensive.

>Is there anyone who does something similar ?   The end result will be
>that students will be able to set the timing for the data logging and
>then put them into the greenhouse and take readings.
>
>Hortocultural students are not electronicaly inclined so the screen
>on the PC would need to be simple.  Maybe even a spreadsheet layout
>with the names of the things and the timing values.

I used to do something similar for some control data logging.  We just 
dumped the data to the terminal as a csv type file that could then be 
imported directly into a spreadsheet.  Something like

A text description to give a short explanation of what the data came from.

nameforcol1,nameforcol2,nameforcol3
1,2,3
4,5,6



It's possible you would need quotes on the column names.  But if you 
capture that in a serial terminal program you can then import that into a 
spreadsheet and you will end up with columns of data with names at the top 
of the columns.  It will probably be easier if you use something other than 
hyperterminal but it will work in a pinch.

If all your data inputs are running at different sample rates it may be 
simpler to dump each one in turn.

You will have to judge if the terminal interface is too difficult for your 
students to master and thus whether you will need to invest in a building a 
menu driven interface.  The menu driven interface could still use the ascii 
serial hookup.

Welcome to the jungle :)
Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.