This interface was completely configured, controlled, and read by a 90LS8535 Atmel AVR (TM).

This is a first attempt with an Atmel AVR (had it for a week so far), and programming with CodeVisionAVR (TM).

In this example:

  • ADC0 is plotted as an analog channel and in gauge 1
  • A variable (count) is plotted as a second analog channel and in gauge 2
  • Port C controlled with the switches
  • Port B input is displayed on the lights and 4 lower bits plotted in digital.

Example code to control plot:
plot_config();                                                                         // send configuration information for gauges, lights, etc
gauge_range(1,0,1200);                                                         // set gauge 1 to 0-1200
gauge_setpoints(1,100,1100);                                                 // set gauge 1 setpoints 100 low, 1000 high
gauge_range(2,-300,300);                                                      // set gauge 2 range -300 to 300
gauge_setpoints(2,-200,200);                                                 // set gauge 2 setpoints -200 low, 200 high
gauge_alarm(1,1);                                                                 // enable alarm on gauge 1
set_labels();                                                                         // call routine to set labels of gauges, etc
switch_set(2,1);                                                                     // turn switch 2 on

putsf("!SPAN 0,1000\r");                                                         // set Y axis span
putsf("!PLOT 1\r");                                                                 // enable plotting
putsf("!RSET\r");                                                                    // reset the plot

while(1)
{
    count++;                                                                               // increment general counter
    delay_ms(500);                                                                     // 500mS delay (appox.)
    printf("!STAT Switch Byte = %d\r",switchByte);                       // place data of sitchByte read in status box
    plot_channel(1,adc_data[0]);                                                 // plot analog channel 1 with ADC0
    plot_channel(2,count);                                                          // plot analog channel 2 with count;
    gauge_set(1,adc_data[0]);                                                   // set gauge 1 value to ADC0
    gauge_set(2,count);                                                             // set gauge 2 value to count
    gauge_label(2,count);                                                          // set gauge 2 label to count value
    plot_digital(4,PINB);                                                             // plot 4 lower bits of PINB in digital
    lights_set(PINB);                                                                 // set Lights to PINB byte
    switches_read();                                                                 // go update switch variables
    PORTC=switchByte;                                                           // Set port C to read switch byte
};

Currently, StampPlot is sending a byte serially of the switch values (at least 1 must be on).  This is read by the AVR to control PORT C.  I have tried to use analog sliders (multiple) for reading analog values from StampPlot, and have had success, but for limited run time.  All instructions to StampPlot must end in a ASCII 13 (\r).  When using scanf for returning data, it wants a ASCII 10 for end of string... gets a little messy....

Example: To read 3 sliders (not shown) called SLD1, SLD2, SLD3

putsf("!READ (SLD1),(SLD2),(SLD3)\r");              // Tell StampPlot to send 3 values, comma separated.
putsf("!BSND 10:);                                             // Send  byte value of 10 from StampPlot to end string.
scanf("\r%d,%d,%d\r\n",Slider1,slider2,slider3) ;   //  Accept returning data and parse into variables

But scanf often causes the controller to lock up awaiting data and other issues, and I decided to move on.

Also, this could be made into a really nice library instead of functions in the main code.

I'm happy to post any better examples, and to provide free licenses for such!

To use this example:

  • Compile and program AVR.
  • Connect the AVR's RXD and TXD, to serial port 
  • Run StampPlot, select no-frills plot.
  • Connect on Stampplot.
  • Reset AVR -- StampPlot configuration should begin.

Links:

 

 

Website and software copyright 2009, SelmaWare Solutions
BASIC Stamp is a registered trademark of Parallax, Inc
XBee is a registered trademark of Digi International
Excel is a registered trademark of Microsoft, Corp.


EST Student Project
Earn your BS in 
Electronic Systems Technologies at  Southern Illinois University Carbondale  Click Here!