Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 04:13 15 May 2024 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 : Keeping it simple

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 911
Posted: 05:57pm 03 Sep 2015
Copy link to clipboard 
Print this post

Just thought I would share a recent project. The need was for a temperature display of some mechanical equipment so I decided for ruggedness and simplicity for reliability. I decided to use a 2 digit 7 segment display, DS18B20 probe and one of the 150 micromites that I have left over from other projects. The only other components required were the 3T reg, couple of caps and a few resistors. The unit can run quite well @ less than 8 mA using 1K0 current limiting resistors to the segments and running lower CPU speeds.

Here's the code:
'******************************************************************************
'* *
'* THIS PROGRAM HAS BEEN WRITTEN FOR THE MICROMITE 150 RUNNING MMBASIC 4.5 *
'* TO READ THE TEMPERATURE FROM A DS18B20 TEMPERATURE PROBE AND DISPLAY ON *
'* 2 DIGIT COMMON CATHODE SEVEN SEGMENT DISPLAY. EACH OF THE SEGMENTS IS *
'* ATTACHED TO THE MMITE VIA A CURRENT LIMITING RESISTOR AND THE COMMON PIN *
'* IS ATTACHED TO VCC SO MINIMAL COMPONENTS ARE BEING USED.(KISS) *
'* THANKS TO GEOFF GRAHAM FOR ALL HIS EFFORTS. GM *
'* *
'******************************************************************************

SetPin 10,DOUT 'DIGIT 1 SEG A
SetPin 7, DOUT 'DIGIT 1 SEG B
SetPin 15,DOUT 'DIGIT 1 SEG C
SetPin 17,DOUT 'DIGIT 1 SEG D
SetPin 16,DOUT 'DIGIT 1 SEG E
SetPin 9, DOUT 'DIGIT 1 SEG F
SetPin 14,DOUT 'DIGIT 1 SEG G
SetPin 4 ,DOUT 'DIGIT 2 SEG A
SetPin 6, DOUT 'DIGIT 2 SEG B
SetPin 22,DOUT 'DIGIT 2 SEG C
SetPin 18,DOUT 'DIGIT 2 SEG D
SetPin 21,DOUT 'DIGIT 2 SEG E
SetPin 5, DOUT 'DIGIT 2 SEG F
SetPin 3, DOUT 'DIGIT 2 SEG G

Dim D1(8),D2(8),NUM(10,8)

'LOAD MMITE PIN NUMBERS TO 7 SEGMENTS OF EACH DIGIT
For D=1 To 7 :Read D1(D):Next D
For E=1 To 7 :Read D2(E):Next E

'LOAD SEGMENT MATRIX FOR EACH NUMBER 0-9
For X=0 To 9
For Y=0 To 7
Read NUM(X,Y)
Next Y
Next X

'CLEAR ALL SEGMENTS
For I=1 To 7
Pin(D1(I))=1
Pin(D2(I))=1
Next I

' MMITE PIN NUMBERS TO EACH 7 SEGMENT DISPLAY
Data 10,7,15,17,16,9,14
Data 4,6,22,18,21,5,3

'7 SEG A B C D E F G MATRIX FOR EACH DIGIT 0-9
Data 0,1,1,1,1,1,1,0 '0
Data 1,0,1,1,0,0,0,0 '1
Data 2,1,1,0,1,1,0,1 '2
Data 3,1,1,1,1,0,0,1 '3
Data 4,0,1,1,0,0,1,1 '4
Data 5,1,0,1,1,0,1,1 '5
Data 6,1,0,1,1,1,1,1 '6
Data 7,1,1,1,0,0,0,0 '7
Data 8,1,1,1,1,1,1,1 '8
Data 9,1,1,1,0,0,1,1 '9

Do
TEMP$=Str$(DS18B20(2),2,0)
Print TEMP$
H=Val(Left$(TEMP$,1))
For J= 1 To 7
If NUM(H,J)=1 Then Pin(D1(J))=0 Else Pin(D1(J))=1
Next J
K=Val(Right$(TEMP$,1))
For J= 1 To 7
If NUM(K,J)=1 Then Pin(D2(J))=0 Else Pin(D2(J))=1
Next J
Pause 1000
Loop

GM
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 12:42am 04 Sep 2015
Copy link to clipboard 
Print this post

Excellent - So simple and effective.

Everyone, don't be shy about sharing projects - the are brain food for others.
Geoff Graham - http://geoffg.net
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 03:09am 04 Sep 2015
Copy link to clipboard 
Print this post

Graeme Meager, I love the approach. Thanks for sharing!!!!
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 911
Posted: 11:50am 04 Sep 2015
Copy link to clipboard 
Print this post

  Geoffg said   Excellent - So simple and effective.

Everyone, don't be shy about sharing projects - the are brain food for others.


Thank you Geoff, I do like the challenge of trying to accomplish the task with the minimum of components.
GM
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 911
Posted: 11:52am 04 Sep 2015
Copy link to clipboard 
Print this post

  viscomjim said   Graeme Meager, I love the approach. Thanks for sharing!!!!

Jim you are very welcome.
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 06:32am 05 Sep 2015
Copy link to clipboard 
Print this post

I love the way you solved this. Simple and elegant, no fluff.
Especially not using byte values for defining the segments for each digit.
So much more clear.

it can be shorter/faster etc but one of the main things that often go wrong with programming is that KISS is often better.

I do have one suggestion and that is not using the pin numbers twice.

Like:
[code]
'******************************************************************************
'* *
'* THIS PROGRAM HAS BEEN WRITTEN FOR THE MICROMITE 150 RUNNING MMBASIC 4.5 *
'* TO READ THE TEMPERATURE FROM A DS18B20 TEMPERATURE PROBE AND DISPLAY ON *
'* 2 DIGIT COMMON CATHODE SEVEN SEGMENT DISPLAY. EACH OF THE SEGMENTS IS *
'* ATTACHED TO THE MMITE VIA A CURRENT LIMITING RESISTOR AND THE COMMON PIN *
'* IS ATTACHED TO VCC SO MINIMAL COMPONENTS ARE BEING USED.(KISS) *
'* THANKS TO GEOFF GRAHAM FOR ALL HIS EFFORTS. GM *
'* *
'******************************************************************************

Dim D1(8),D2(8),NUM(10,8)

'LOAD MMITE PIN NUMBERS TO 7 SEGMENTS OF EACH DIGIT AND MAKE THEM OUTPUTS
For D=1 To 7 :Read D1(D): SetPin D1(D), DOUT:Next D
For E=1 To 7 :Read D2(E): SetPin D2(E), DOUT:Next E

'LOAD SEGMENT MATRIX FOR EACH NUMBER 0-9
For X=0 To 9
For Y=0 To 7
Read NUM(X,Y)
Next Y
Next X

'CLEAR ALL SEGMENTS
For I=1 To 7
Pin(D1(I))=1
Pin(D2(I))=1
Next I

' MMITE PIN NUMBERS TO EACH 7 SEGMENT DISPLAY
'Segments A,B,C,D,E,F,G
Data 10,7,15,17,16,9,14 'First segment
Data 4,6,22,18,21,5,3 'Second segment

'7 SEG A B C D E F G MATRIX FOR EACH DIGIT 0-9
Data 0,1,1,1,1,1,1,0 '0
Data 1,0,1,1,0,0,0,0 '1
Data 2,1,1,0,1,1,0,1 '2
Data 3,1,1,1,1,0,0,1 '3
Data 4,0,1,1,0,0,1,1 '4
Data 5,1,0,1,1,0,1,1 '5
Data 6,1,0,1,1,1,1,1 '6
Data 7,1,1,1,0,0,0,0 '7
Data 8,1,1,1,1,1,1,1 '8
Data 9,1,1,1,0,0,1,1 '9

Do
TEMP$=Str$(DS18B20(2),2,0)
Print TEMP$
H=Val(Left$(TEMP$,1))
For J= 1 To 7
If NUM(H,J)=1 Then Pin(D1(J))=0 Else Pin(D1(J))=1
Next J
K=Val(Right$(TEMP$,1))
For J= 1 To 7
If NUM(K,J)=1 Then Pin(D2(J))=0 Else Pin(D2(J))=1
Next J
Pause 1000
Loop
[/code]



Microblocks. Build with logic.
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 911
Posted: 01:14pm 05 Sep 2015
Copy link to clipboard 
Print this post

  TZAdvantage said   I love the way you solved this. Simple and elegant, no fluff.
Especially not using byte values for defining the segments for each digit.
So much more clear.

it can be shorter/faster etc but one of the main things that often go wrong with programming is that KISS is often better.

I do have one suggestion and that is not using the pin numbers twice.

Like:
[code]

'LOAD MMITE PIN NUMBERS TO 7 SEGMENTS OF EACH DIGIT AND MAKE THEM OUTPUTS
For D=1 To 7 :Read D1(D): SetPin D1(D), DOUT:Next D
For E=1 To 7 :Read D2(E): SetPin D2(E), DOUT:Next E

[/code]



Thank you Jean for your kind comments. I used the verbose code for the setpins mainly to explain the wiring that I used. Your change does make the code shorter.
GM
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 911
Posted: 01:22pm 05 Sep 2015
Copy link to clipboard 
Print this post

I was thinking and IIRC 2-1/2 digit led displays were used for the cpu speed readout on the early clone AT pc's. If I used one of these I could extend the range by another 100 degrees for the use of one more spare pin on the mmite.

I wonder if these 2-1/2 digit seven segment leds are still readily available or if there is any chance I might find one that I have removed from a case before disposal in the many, many boxes of historic components that I have collected over the years.

GM
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 712
Posted: 11:18pm 05 Sep 2015
Copy link to clipboard 
Print this post

Hi,

so simple that i don't understand it😞.

Where uses the read command in the do...loop the Data fields?

Maybe i don't understand the usage of DATA and READ......

THX

 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 911
Posted: 11:55pm 05 Sep 2015
Copy link to clipboard 
Print this post

  atmega8 said   Hi,

so simple that i don't understand it😞.

Where uses the read command in the do...loop the Data fields?

Maybe i don't understand the usage of DATA and READ......

THX


Atmega, not exactly sure of your the translation of your post (I might be having problems with your accent)
I have set up some arrays both 8 X 1 as for the pins connected to each of the seven segments of each display digit. ( used 8 locations so I could cover the decimal point which I have not used) Then a 10 X 8 array (or table if you like) to represent the segments of each digit 0-9 that will be necessary to be activated for each digit to be displayed. This time I used the first location of each row in the table to hold the digit (0-9), (again this is not necessary but does not cost a lot of memory) and the following 7 locations hold the information of which segment needs to be illuminated to represent each digit.

Using the READ statement loads each of the array or table entries sequentially from the DATA statements (which only needs to be done once in the program) and they are held as solid reference as long as the program runs.

Hope my accent doesn't confuse the issue any more.
Best Regards
GM
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 712
Posted: 07:32pm 06 Sep 2015
Copy link to clipboard 
Print this post

Aha,

Read picks one by one from the DATA Fields...

And restore beginns again from he Top.

Idea:

If the Pins of The Segments where in Order by Pin Numbers, we Could use the Port command.
Think this would give a more simpler programm?!
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 911
Posted: 10:52pm 07 Sep 2015
Copy link to clipboard 
Print this post


Found one.......




After an extensive search of the workshop I located the said items

And guess what? The electric jug does boil at 100 degrees Celsius according to the DS18B20.

GM
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 04:23am 08 Sep 2015
Copy link to clipboard 
Print this post

But did you check the atmospheric pressure?
Without measuring that the measurements are meaningless.









Only kidding.
It is simple and useful. MMBasic at its best.

Do you have experience with measuring higher temperatures.
I am in need of measuring the temperature of air that is coming out of a hot air soldering station. That goes up to almost 300.
I want to do an experiment using a controlled airflow/temperature to reflow small pcb's.


Microblocks. Build with logic.
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 12:41pm 08 Sep 2015
Copy link to clipboard 
Print this post

Hi Graeme,

Fantastic... I like it..

One question if I may... How do you drive the 3rd digit to get the 1 in 100? You dont seem to support that in your code (at least that my feeble eyes can see)

Regards,

Mick

PS. Remember I still owe you some money/boards so don't let me skip town on you.

Regards,

Mick


Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 911
Posted: 01:18pm 08 Sep 2015
Copy link to clipboard 
Print this post

@ TZ I know that I am a couple of hundred meters above sea level so being the scientist I am, I compensated and put the kettle on the floor

@ Mick, I will post the amended code when I am back in the workshop.

GM
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 911
Posted: 04:41pm 08 Sep 2015
Copy link to clipboard 
Print this post

HERE IS THE LOOP MODIFIED FOR THE THIRD DIGIT. THE ONLY PREREQUISITE IS SETPIN(23),DOUT TO DRIVE THE 100'S DIGIT.

Do
TRTEMP=DS18B20(2)
TEMP$=Str$(TRTEMP,2,0)
Print TRTEMP

H=Val(Right$(TEMP$,1))
For J= 1 To 7
If NUM(H,J)=1 Then Pin(D1(J))=0 Else Pin(D1(J))=1
Next J

If Val(TEMP$) < 100 Then
Pin(23)=1
K=Val(Left$(TEMP$,1))
For J= 1 To 7
If NUM(K,J)=1 Then Pin(D2(J))=0 Else Pin(D2(J))=1
Next J
Else
Pin(23)=0
K=Val(Mid$(TEMP$,2,1))
For J= 1 To 7
If NUM(K,J)=1 Then Pin(D2(J))=0 Else Pin(D2(J))=1
Next J
EndIf

Pause 1000
Loop


GM
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 911
Posted: 05:52pm 08 Sep 2015
Copy link to clipboard 
Print this post

@TZ
  Quote  Do you have experience with measuring higher temperatures.
I am in need of measuring the temperature of air that is coming out of a hot air soldering station. That goes up to almost 300.
I want to do an experiment using a controlled airflow/temperature to reflow small pcb's.


The DS18B20 probes that I am using are only good to 125 C so that has been the limit of my experience in mmbasic temperature measurement.

GM
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 06:14pm 08 Sep 2015
Copy link to clipboard 
Print this post

  TZAdvantage said   Do you have experience with measuring higher temperatures.
I am in need of measuring the temperature of air that is coming out of a hot air soldering station. That goes up to almost 300.
I want to do an experiment using a controlled airflow/temperature to reflow small pcb's.

TZ, I guess you mean 300oC as most of the world does, excluding the USA? Your best bet is a normal Type K (chromel/alumel) thermocouple. They have the yellow connectors and are the ones usually assumed for DVM's that also measure temperature. They're readily available in stainless steel probes about 150mm length and various diameters - approx 2mm is common and would have a pretty quick response for what you need.

Thermocouples are pretty much only good for +/- 2 or 3oC at best, without going to a lot of trouble, but I guess that's probably OK for your job. A platinum resistance thermometer can be more accurate but 300oC is getting towards the top of their range.

BTW I assume you know about the cold junction compensation required for thermocouples?

Greg
 
Print this page


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

© JAQ Software 2024