Go Down

Topic: Voltage Time Graph - GLCD (192x64) (Read 1 time) previous topic - next topic

graymalkin

Hi all,
I refrain from calling this a scope on this forum because we know it isn't, but it is quite close to what an Arduino could call a scope, right?  ;)
Anyway, there is now a video on YouTube.  I am going to try to add some logging to it, but I need a new thermistor first (I might have melted the last one, hense the croc clip as a probe :P)

Anyway, here is the video:

[media]http://www.youtube.com/watch?v=FTFTgq19RPM[/media]

/me

cr0sh

A few comments:

1) Nice - and ugly - but nice!
2) Get a tripod...
3) Get a macro lens...
4) Get me outta here!
5) Code? Schematic? Please?

Seriously - that looks interesting, it was hard to follow what was going on with all the bouncing around, but the basics could be seen.

Something that I have thought about doing (but will probably never get around to) is using an Arduino and a GLCD to create a simple digital logic analyser; basically quickly sampling one port (6 bits) for HIGH/LOW transitions using direct port I/O in the quickest manner possible (likely using an unrolled loop), and storing the results in memory (triggered off one of the pins in the port, an internal trigger, or a different external trigger pin), then showing the results on the GLCD (scrolling, zooming, examining different pins side-by-side, allowing for a dump to the serial port, etc).

While it wouldn't be fast, for most users of the Arduino I think it could be very useful...

:)
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

pluggy

Quote
5) Code? Schematic? Please?


Times two.....  :)
http://pluggy.is-a-geek.com/index.html

graymalkin

#3
Apr 27, 2010, 10:31 pm Last Edit: Apr 27, 2010, 10:59 pm by Gray_Malkin Reason: 1
The code has developed from when this was shot (only hours ago) - sorry about the shakey camera man, but it was the best I could do (am student therefore skint)

Code:
Code: [Select]
#include <EEPROM.h>
#include <ks0108.h>
#include "SystemFont5x72.h"  // system font
#include "ArduinoIcon.h"     // bitmap

unsigned long startMillis;
unsigned int loops = 0;
unsigned int iter = 0;
int Benchcount = 0;
int InputPin = 5;
int PlotVoltage = 0;
int VoltageValue = 0;
int DisplayFromEEPROM = 1;  // 0 = Record, 1 = Display
int EEPROMPosition = 0;     // Store the current location in memory.
int d = 1;
 int p = 0;
 int x = 0; //x graph coordinate
 int y = 0; //y graph coordinate
 int a = 0; //old x graph coordinate
 int b = 0; //old y graph coordinate

int delayTime = 1000;        // Change how often data is recorded (will change recording duration - total (MS) = 512 * delayTime)

// Get things ready
void setup(){
 GLCD.Init(NON_INVERTED);   // initialise the library, NON_INVERTED writes pixels onto a "white screen"
 GLCD.ClearScreen();        // Clear the GLCD Screen memory ready for drawing on.
 GLCD.SelectFont(new_Font); // switch to fixed width system font
}


void  loop(){   // run over and over again
 // TODO:
 //  o Add a physical toggle for read/record
 //  o Add more information down the right side
 //    - High
 //    - Low
 //    - Mode (playback, reccording)
 //  o Add some welcome images and even Images
 //  o Maybe add Mass storage for logging
 //  o Add another line from another pin out?
 //  o Serial out the readings
 //  o Add a pause between readings so the memory doesn't fill so quickly
 //     and more information is on the graph
 //      - Ajustable by a POT
 //      - Change the playback speed for long "exposure" graphs, so time travels faster.
 //  o Buy a Thermistor and perhaps record tempreture
   
 //Dotted Line to Center Plot Graph Area Horizontally
 d = 0;
 for (int i=0; i <= 63; i++){ //dotted graph line
   GLCD.SetDot(d, 32, BLACK);
   d = d + 2;
 }

 GLCD.DrawRect(0,0,128,63, BLACK);
 
 static float p;
 static float x;
 
 // Erase Previous Information Panel Pixels
 GLCD.FillRect(129, 0, 64, 62, WHITE);
 
 if(DisplayFromEEPROM == 0)
 {
   //Read input
   PlotVoltage = analogRead(InputPin);  // Each byte of EEPROM memory can hold 1 reading. So a ATMega 328 can store 512 readings.  About 3 screens full.
   
   if(EEPROMPosition > 511)
   {
    EEPROMPosition = 0;
   }
   //Record Input
   EEPROM.write(EEPROMPosition, PlotVoltage / 4);
   
   GLCD.GotoXY(130,22);
   GLCD.Puts("Recording");
 }
 else
 {
   if(EEPROMPosition > 511)
   {
    GLCD.ClearScreen();
    GLCD.CursorTo(0,0);
    GLCD.Puts("End of memory, restarting");
    GLCD.CursorTo(0,2);
    GLCD.Puts("To change record speed please");
    GLCD.CursorTo(0,3);
    GLCD.Puts("edit the loop delay.");
    delay(5000);
    GLCD.ClearScreen();
    EEPROMPosition = 0;
   }
   GLCD.GotoXY(130,22);
   GLCD.PutChar(127);// 127 the address of the Play symbol in the "System" font.
   GLCD.Puts("Playback");
   
   // Read Input
   PlotVoltage = EEPROM.read(EEPROMPosition) * 4;
 }
 
 //Move on the EEPROM Read Location
 EEPROMPosition++;
 
 VoltageValue = (PlotVoltage / 2.04799979);
 int whole = VoltageValue / 100;
 int fraction = VoltageValue - whole * 100;
   
 // Write the progress through the memory (reading or writing)
 GLCD.GotoXY(130, 34);
 int progress =  EEPROMPosition * 0.1953125;
 GLCD.PrintNumber(progress);
 GLCD.Puts("%  Prog");
 
 //Draw Rectangles on top and bottom corners to display RAW Data from Analog Reading
 GLCD.GotoXY(130,02);
 GLCD.Puts("Bin: ");
 GLCD.PrintNumber(PlotVoltage);          

 GLCD.GotoXY(130, 12);
 GLCD.Puts("");
 GLCD.PrintNumber(whole);
 GLCD.PutChar('.');
 GLCD.PrintNumber(fraction);
 GLCD.GotoXY(158, 12);
 GLCD.Puts("Volt");
 
 if (PlotVoltage > p){ //print peak graph value
    // GLCD.FillRect(97, 05, 29, 10, WHITE);
    // GLCD.GotoXY(98,119);
    // GLCD.PrintNumber(PlotVoltage);
    p = PlotVoltage;
 }
 
//Add Scaling...Bottom most line (y=63 is 0V, y=1 is 5V)
GLCD.DrawLine(0, 0, 0, 63, BLACK);  //Line for Scaleing Tally Marks
GLCD.DrawLine(0, 0, 4, 0, BLACK);   //Topmost Mark
GLCD.DrawLine(0, 8, 2, 8, BLACK);
GLCD.DrawLine(0, 16, 4, 16, BLACK);
GLCD.DrawLine(0, 24, 2, 24, BLACK);
GLCD.DrawLine(0, 32, 4, 32, BLACK); //Center Mark
GLCD.DrawLine(0, 40, 2, 40, BLACK);
GLCD.DrawLine(0 ,48, 4, 48, BLACK);
GLCD.DrawLine(0, 56, 2, 56, BLACK);
GLCD.DrawLine(0, 63, 4, 63, BLACK);//BottomMost Mark

 
 int y = 63 - (PlotVoltage /16);   //y coordinate of graph curve  ***Careful when adjusting the '/16' part. Y should be where you want the lowest reading displayed and
 if(b == 0){                       //                            the divisor number adjusts the scaleing (sensitivity) based on where that line is...
 b = y;                            //                            The lower the number, the higher sensitivity/max reading is plotted on graph
 }
 
 GLCD.DrawLine(a,b,x,y, BLACK);
 x++;                              // Add 1 to old x coordinate for line drawing in right direction
 
 if (x == 128){                    //clean screan when graph cycle will start again from left
 GLCD.ClearScreen();
 x = 0;                            //x coordinate to start graph from left again

 }
 
 a = x;                           //old x coordinate to use for drawing line to new x coordinate
 b = y;                           //old y coordinate to use for drawing line to new y coordinate
 
 delay(delayTime);                //Make the memory "last" longer by taking readins less often
}


I modified the code out of a post from Metalfan1185.  I changed it to support 192x64 screen size, then I added some recording and commented it a little more.  After this you can see my todo list.  Originally the delay in the loop wasn't explicit but caused by calculation time, I have added a delay (and ajustablility) to the loop too to change the recording duration.

Data is automatically logged in the EEPROM, if you have anything important in yours I suggest you comment out the writing part should you run the program.
[edit]I may also buy an EEPROM chip standalone for the storage (as opposed to an SD card) and perhaps show elapsed time too.[/edit]

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy