Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:59 05 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : explore 100 graphs

Author Message
kev1950
Newbie

Joined: 24/08/2016
Location: Australia
Posts: 4
Posted: 08:05pm 04 Nov 2016
Copy link to clipboard 
Print this post

Hi a newbie I have assembled a Explore 100 kit, a would like to display a few analog values on a graph. Is there any suitable code I could look at for inspiration? would like to scroll backwards to check on old data.

thanks
kevin
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 09:11pm 05 Nov 2016
Copy link to clipboard 
Print this post

Welcome to the forum and micromite fan.

How you chart things really depends on what it is that you are displaying.
You can easily do barcharts by printing a line from y=0 to y=value for each X
You can do a line chart by printing a line from the last x,y value to the current x,y value
The third method is a simple dot at each point.
This is what I have done on the attached program. It was written for the maximite and I have done a quick and dirty conversion for the Explore64 with 7inch display.

The program is a heartrate monitor and continually overwrites the old data.
The first thing I noticed is the small size of the single pixels. I would normally draw a small circle instead of a single pixel for each point. That makes it much more readable.

The other thing I noticed is I will have to go back to the cardiologist again - bugger.

  Quote  
' pulse monitor
' 4 Apr 2014
' TassyJim
' changed for explore64 with 7inch LCD 6 NOV 2016
' pin 53 connected to the pulse detector.
' www.seeedstudio.com/depot/Grove-Earclip-Heart-Rate-Sensor-p-1116.html
'
' pin 52 used as an output to LED or CRO etc.
'
' C clear screen and start again
' L start logging data to file (will append to same date file)
' X stop logging to file
' ^C to quit.

pulsepin =
53
ledpin =
52
CLS
samples=
12
DIM av(samples)
SETPIN pulsepin, INTH, beat
SETPIN ledpin, DOUT ' LED
PIN(ledpin) = 0
beatTime =
TIMER
GOSUB chart
tick$ =
MID$(TIME$,7,1)
DO
testtime=
TIMER
IF (testtime-beattime)>6000 THEN
TEXT 1,10, "No pulse detected! "
beatTime =
TIMER
pStart=
0
ENDIF
k$=
INKEY$
'If k$="P" Or k$="p" Then SaveBMP "pulse.bmp"
IF k$="C" OR k$="C" THEN
CLS
GOSUB chart
x=
0
ENDIF
IF k$="L" OR k$="L" THEN
filename$=
MID$(DATE$,9,2)+MID$(DATE$,4,2)+LEFT$(DATE$,2)+".csv"
IF logit = 0 THEN OPEN filename$ FOR append AS #2
PRINT #2, DATE$;" ";TIME$;" Start"
PRINT #2, "Time,Pulse,Average"
logit=
1
ENDIF
IF k$="X" OR k$="X" THEN
'filename$=mid$(date$,9,2)+mid$(date$,4,2)+left$(date$,2)+".BAS"
IF logit = 1 THEN
PRINT #2, DATE$;" ";TIME$; " Closed"
CLOSE #2
ENDIF
logit=
0
ENDIF
IF tick$ <> MID$(TIME$,7,1) THEN
tick$ =
MID$(TIME$,7,1)
LINE x+39,60,x+39, 70,1, RGB(WHITE)
ENDIF
LOOP

IF logit = 1 THEN CLOSE #2

END

beat:
beatTimeNow =
TIMER
beatPeriod=beatTimeNow-beatTime
beatTime=beatTimeNow
PULSE ledpin, 40
IF beatperiod > 5 AND beatperiod < 3000 THEN
pulseRate=
INT(60000/beatPeriod+.5)
s= x
MOD samples
pav=pav-av(s)+ pulserate
av(s)=pulseRate
GOSUB clr_ahead
pr$=
STR$(pulseRate,3)
IF pStart>0 THEN
PIXEL x+40,300-pulserate, RGB(YELLOW)
ENDIF
IF pStart > samples THEN
ave=
INT(pav/samples+0.5)
avg$=
STR$(ave,3)
PIXEL x+40,300-ave, RGB(RED)
TEXT 1,10, "Pulse rate: "+pr$+" Pulse av: "+avg$+" "
ELSE
TEXT 1,10, "Pulse rate: "+pr$+" "
pStart = pStart +
1
ENDIF
IF logit = 1 THEN
PRINT #2, TIME$+","+pr$+","+avg$
ENDIF
x = (x+
1) MOD 360
ENDIF
IRETURN

chart:
CLS
FOR ys = 0 TO 240 STEP 20
y =
300 - ys
LINE 40,y,400, y, 1,RGB(BLUE)
TEXT 5,y-5, STR$(ys)
NEXT ys
RETURN

clr_ahead:
LINE x+40,300,x+50,0, 1,RGB(BLACK)
FOR ys = 0 TO 240 STEP 20
y =
300 - ys
LINE x+40,y,x+46, y, 1,RGB(BLUE)
NEXT ys
RETURN


Remember that this code started out before we had integers and variable declarations.

You will probably want to change the input pin to something other than pin 53 and a simple switch to 3.3v and a pulldown resistor will do to simulate the pulse detector.

Jim
VK7JH
MMedit
 
kev1950
Newbie

Joined: 24/08/2016
Location: Australia
Posts: 4
Posted: 10:12pm 05 Nov 2016
Copy link to clipboard 
Print this post

Thanks for your response,I will look closely at it through the week when I have time, I'am a little out of my comfort zone at this stage.
regards
kev
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1114
Posted: 01:01am 06 Nov 2016
Copy link to clipboard 
Print this post

Kev,

I also have a graphing program for the Micromite plus and a 7" display. It displays the values of several analog inputs on the top half and then a running graph showing all the values over a 6 hour period -it keeps running at the end of the 6 hour period and starts over. Graph steps are 1 min intervals. Happy to send a copy if you want.
Doug.

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
kev1950
Newbie

Joined: 24/08/2016
Location: Australia
Posts: 4
Posted: 10:12am 06 Nov 2016
Copy link to clipboard 
Print this post

Thanks Doug I would love to see your program, my end goal is to monitor the power usage around the house (using non contact CT's). Then switch off items like pool & watering systems to maximize Solar usage.

Thanks
Kevin

Email Jusroamin@gmail.com
 
Cremo
Newbie

Joined: 21/07/2015
Location: Italy
Posts: 36
Posted: 11:16pm 06 Nov 2016
Copy link to clipboard 
Print this post

Hi panky,
I am interesed in your program for Micromite Plus to display several analog inputs and a running graph.
I would like to receive a copy.
My mail addres is: pietro@ingcremonini.it.
Thank you a lot.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025