Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: Newie got a few questions Post ReplyPost New Topic
<< Prev Page of 34 Next >>
Author
Message << Prev Topic | Next Topic >>
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 925
Posted: 06 December 2017 at 11:26pm | IP Logged Quote lew247

Thanks Panky

On a different subject again

I have a picture displayed on the lcd screen showing various information
What I would LIKE to do is
IF my outdoor unit lost the GPS lock
or was faulty - not sending information for a set period of time

display a message on the Explore 100 lcd
similar to
Text 150,150,"GPS LOCK LOST" , LM, 2, 3, RGB(BLACK), RGB(WHITE) 'Print the weather description
or
Text 150,150,"Outdoor unit FAULTY" , LM, 2, 3, RGB(BLACK), RGB(WHITE) 'Print the weather description
BUT
I'd like to remove the text after a set period of time and have the original picture show
Is there a way to remove text without having to load the picture fully again?



Back to Top View lew247's Profile Search for other posts by lew247
 
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 925
Posted: 06 December 2017 at 11:56pm | IP Logged Quote lew247

I sorted the problem partly by using led's on the screen, its easy to turn them on and off

Is there a way to set a timer on a serial port so that if nothing is received within a set period of time it then does something such as change a ctrlval
Back to Top View lew247's Profile Search for other posts by lew247
 
goc30
Regular Member
Regular Member
Avatar

Joined: 12 April 2017
Location: France
Online Status: Offline
Posts: 66
Posted: 07 December 2017 at 12:10am | IP Logged Quote goc30

you must use a time-out couter


'------------------
'init var
dim tcpt1 as integer  'value of time out counter
dim tcpt2 as integer   'value of display counter
dim tcptmax as integer   'value max of time out
dim tcptmax2 as integer   'value of display time
SETTICK 100, gpsto  (or settick 100, gpsto,x  'x=n couter if use more than 1 coutner

'---------------
'in setup 
tcpt1=0
tcptmax=30  'wait 3 sec time out
tcptmax2=50  'display msg during 5 sec

'-------------------
'after gps on
tcpt1=1   to begin couting
'-------------------
'in main loop
'...
'... others tasks  
'...
' if not use COM time-out you must put this
tcpt1=1  'for begin couting time out "no response"
'gps read  'and goto read COM gps
'
'if gps value is correct
tcpt1=1   'raz time-out
tcpt2=0   'raz display
'...
'... 
'----------------
'in interrupt sp
gpsto:
if tcpt2=0 then
      tcpt2=1   'flag display is done
      Text 150,150,"           " , LM, 2, 3, RGB(BLACK), RGB(WHITE) 'Print the
end if

if tcpt1<tcptmax then
   if tcpt1>0 then tcpt1=tcpt1+1
else
   if tcpt1=tcptmax then
       tcpt1=tcpt1+1  'to indicat timeout is on and no display next time
       Text 150,150,"GPS LOCK LOST" , LM, 2, 3, RGB(BLACK), RGB(WHITE) 'Print
       tcpt2=1  'begin counting display time
            'and add other instruct if necessary
   else
       if tcpt2<tcptmax2 then
          if tcpt2>0 then tcpt2=tcpt2+1
       else
          tcpt2=0  'for raz display in next loop
       end if
   end if
end if

ireturn


if you work in interrupt mode for gps, it is more easy
you need to put a flag "gps ok", or put cpt1 to 1 (and cpt2 to zero if not) after decoding ans control string gps



Edited by goc30 on 07 December 2017 at 12:33am
Back to Top View goc30's Profile Search for other posts by goc30
 
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 925
Posted: 29 December 2017 at 10:30pm | IP Logged Quote lew247

Could my soldering be the reason this board isn't working?
I "attempted" to solder SMD the other day to save someone having to do it yet again for me but I failed, it doesn't work!
Guess my eyesight and hand/eye co-ordination isn't what it used to be - I "used" to be a tv tech years ago and was able to solder smd back then!

Good examples of how "NOT" to solder




Back to Top View lew247's Profile Search for other posts by lew247
 
Azure
Guru
Guru
Avatar

Joined: 09 November 2017
Location: Australia
Online Status: Offline
Posts: 300
Posted: 30 December 2017 at 6:34pm | IP Logged Quote Azure

Some of those SMD joints look a bit suspect but may be OK, just becuase they are not square doens't make them bad joints. Check both side are soldered and they are not bridged under the compement to short it out.

You should check the 5V rail at the processor socket (chip removed) preferably with a scope to see if it is clean with minimal noise but a meter will suffice.

You should also check that cap under the processor, if it is the one connected to pin 20, it is supposed to be a tantalum 47uf or usually a 10uF X5F non polarised ceramic. It looks more like an electrolytic which won't work properly.

Other things to try, does the MM work in another board (shows it is programmed and working correctly).

After those thing then normal checks like reset line and any stuck pins will depend on your experience and available tools.
Back to Top View Azure's Profile Search for other posts by Azure
 
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 925
Posted: 01 January 2018 at 5:54am | IP Logged Quote lew247

It's alive - no idea how but it is
I resoldered the tantalum cap connected to the MM and put 3mm led's on the board instead of the smd ones and it now works
Miracles do happen!


Edited by lew247 on 01 January 2018 at 5:55am
Back to Top View lew247's Profile Search for other posts by lew247
 
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 925
Posted: 04 January 2018 at 5:06am | IP Logged Quote lew247

Can anyone help with a time routine please?

On an Explore 100 board I have an audio board connected and I want it to chime on the hour and at 15 min intervals

I have an RTC connected
and in the code I have
hrs = Val(left$(Time$,2)) ' FOR INFO ONLY
mins = Val(Mid$(Time$,4,2)) ' FOR INFO ONLY
secs = Val(right$(Time$,2)) ' FOR INFO ONLY

I tried this

IF Val(left$(Time$,2)) = 19 and Val(Mid$(Time$,4,2)) = 00 and Val(right$(Time$,2) = 01
print "19:00:01 and I work"
END IF

However that just printed "19:00:01 and I work" continuously

I then tried

IF Val(left$(Time$,2)) = 19 THEN  
print "19:00:01 and I work"
END IF


But this doesn't work either, it prints it continuously again

What I want to do is trigger a pin on each hour like this


 IF Val(left$(Time$,2)) = 14 then
   PIN(91) = 0                'Chime on
   print "2PM Chime on"       'print so I know it's working
  pause 150                   'trigger delay for audio board
  PIN(91) = 1                 'Audio board off
   pause 4250                 'pause for the 1st hour chime to play
   PIN(91) = 0                'Chime 2nd time
    pause 150                 'trigger delay for audio board
  PIN(91) = 1                 'Audio board off




Edited by lew247 on 04 January 2018 at 5:07am
Back to Top View lew247's Profile Search for other posts by lew247
 
JohnS
Guru
Guru


Joined: 18 November 2011
Location: United Kingdom
Online Status: Offline
Posts: 1660
Posted: 04 January 2018 at 7:42am | IP Logged Quote JohnS

If it's in a loop the time won't count up a second for many loops.
(You'd want something like to store the time and check if it's changed from the old value and only then check if it's the time when you want to print.)

Similar idea if in a tick routine.

John
Back to Top View JohnS's Profile Search for other posts by JohnS
 
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 925
Posted: 05 January 2018 at 4:05am | IP Logged Quote lew247

I've got it sorted apart from the time display freezes while the chimes sound

I have the following code for the time and clock routines

SetTick 1000,UpDateTime    ' Call every second, print date/time
do
main program
  IF NewDataFlag = 1 then
      TEXT 330,238, TIME$, LM, 1, 2, RGB(BLACK),RGB(white)                                           'Print the Time
      Text 285,275, DOW$(DayOfWeek(Year, Month, Day))+" " +date$, LM, 2, 1, RGB(BLACK), RGB(WHITE)   'Print the Day of week
      NewDataFlag = 0
    End IF

Sub UpDateTime ' called by 1 second interrupt from SetTick
Local hrs,mins,secs
hrs = Val(left$(Time$,2))
mins = Val(Mid$(Time$,4,2))
secs = Val(right$(Time$,2))
DOW$(0)="Sunday":DOW$(1)="Monday":DOW$(2)="Tuesday":DOW$(3)= "Wednesday":DOW$(4)="Thursday":DOW$(5)="Friday":DOW$(6)="Saturday" ' Day of the week
' Get the current time, extract the minutes component
If secs = 0 Then  
  MinFlag = 1
Else
  MinFlag = 0
EndIf
If hrs = 23 And mins = 59 And secs = 59 Then   'check for gmt/bst - this comes from GPS unit
Text 285,275, "                    ", LM, 2, 1, RGB(BLACK), RGB(WHITE)
  RTC GETTIME
  EODFlag = 1
Else
  EODFlag = 0
EndIf
Year=Val(Mid$(Date$,7,4)):Month=Val(Mid$(Date$,4,2)):Day=Val(Mid$(Date$,1,2))
NewDataFlag = 1 ' set to indicate fresh data
End Sub


That all works fine

It's the hour chimes I'm having problems with
I'm using the Westminster Chimes on an Adafruit board and I have 6 chimes I can use
0 - 3 = 1/4, 2/4. 3/4 and 4/4 chimes
output 4 is the 1 hour Chime which repeats depending on what hour it is, ie for 7 PM it would play and repeat 6 times
Chime 5 is the Midday Chime - 12 chimes in one file so that isn't a problem

My code for playing the hour chime is as follows


IF Val(left$(Time$,2)) = 07 and Val(Mid$(Time$,4,2)) = 00 and Val(right$(Time$,2)) = 00 then
   PIN(91) = 0              'PIN(91)ON    
   print "7AM Chime ON"     'So I can see it's working if the sound stops
  pause 150                 'Delay to ensure sound board plays
  PIN(91) = 1               'Turn PIN(91) OFF
  pause 4250                'Delay while the chime plays
   PIN(91) = 0              'Turn PIN(91) ON again
    pause 150
  PIN(91) = 1
     pause 4250
   PIN(91) = 0
    pause 150
  PIN(91) = 1
     pause 4250
   PIN(91) = 0
    pause 150
  PIN(91) = 1
 pause 4250
   PIN(91) = 0
    pause 150
  PIN(91) = 1
   pause 4250
   PIN(91) = 0
    pause 150
  PIN(91) = 1
   pause 4250
   PIN(91) = 0
    pause 150
  PIN(91) = 1
END IF


Thats the code for 7AM and also 7PM but the hour changed to 19 instead of 07

I need the pause of 150 after I make PIN(91) = 0 to make sure the sound board will play
Then I need a pause of 4250 because thats how long in total each chime takes to play.


IS there any way to do with while keeping the clock updating on the display or will I just have to accept the clock pausing while playing the chimes?


Edited by lew247 on 05 January 2018 at 4:07am
Back to Top View lew247's Profile Search for other posts by lew247
 
Azure
Guru
Guru
Avatar

Joined: 09 November 2017
Location: Australia
Online Status: Offline
Posts: 300
Posted: 05 January 2018 at 12:34pm | IP Logged Quote Azure

You chime routine can be compacted and more efficient and also get rid of the pauses.

It needs to ignore 12/24 hour by taking the hour mod 12 so you are only ever dealing with 0-11, with zero being 12:00/00:00). We offset it by 1 to stop multiple triggering for the midday chime.

If it is 1 (on the hour of midday/midnight) play chime 05.

If it is 2-12 (on the hour other than midday/midnight) set a flag/counter to play the 04 chime 'hour' times.

In the HourChime routine decrement the counter and if needed play the 04 Chime.

Use the 'PULSE 91, 150' command to generate the pulse on the pin to remove the PAUSE 150.

Use a SETTICK timer instead of PAUSE 4250 (which will need to be 4250+150 = 4400).

Here is something along those lines (not tested), hope it helps:


PS This Weather station is a big proect
'Generic words used for hours, minutes and seconds, these need to be properly coded

'Define the pins used for the midday and hourly chimes
CONST middayPin xx
CONST hourPin   91

'HourFlag > 0 play chimes, value is number of hourly chimes to play + 1
DIM INTEGER HourFlag = 0

'Check if we are on the hour and have not started the chimes
IF (minutes = 0) AND (seconds = 0) AND (HourFlag = 0) THEN
  HourFlag = (hours mod 12) + 1    '+1 used to stop midday from multiple triggering
  SETTICK 4400, HourChime, 2       'Using tick 2 as hourly chime delay
  IF HourFlag = 1 THEN
    PULSE middayPin, 150           'Play the midday chime
  ELSE
    HourChime                      'Play first hourly chime
  ENDIF
ENDIF

'Play the hourly chime stop when all done
SUB HourChime
  HourFlag = HourFlag - 1          'count them down
  IF HourFlag = 0 THEN             'If we just played the last one needed
    SETTICK 0,,2                   'then reset the tick we were using
  ELSE
    PULSE hourPin, 150             'Play the hourly chime
  ENDIF
ENDSUB



Edited by Azure on 05 January 2018 at 9:30pm
Back to Top View Azure's Profile Search for other posts by Azure
 
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 925
Posted: 05 January 2018 at 10:50pm | IP Logged Quote lew247

Thanks Azure, that's much neater
However I used 24 hour clock to enable easily "not playing" the chimes after 10PM
but that isn't important
I tried your code and used the following
SETPIN 97, DOUT            '1/4 hour chime
  SETPIN 96, DOUT            '2/4 hour chime
  SETPIN 95, DOUT            '3/4 hour chime
  SETPIN 92, DOUT            '4/4 hour chime
  SETPIN 91, DOUT            'Hour chime
  SETPIN 90, DOUT            'Long Hour chime
  CONST middayPin = PIN(90)
  CONST hourPin = PIN(91)
  PIN(97) = 1                'Chime off
  PIN(96) = 1                'Chime off
  PIN(95) = 1                'Chime off
  PIN(92) = 1                'Chime off
  PIN(91) = 1                'Chime off
  PIN(90) = 1                'Chime off
  Hours = Val(left$(Time$,2))
  Minutes = Val(Mid$(Time$,4,2))
  Seconds = Val(right$(Time$,2))

DO
 IF Val(Mid$(Time$,4,2)) = 00 and Val(right$(Time$,2)) = 00 then
   PULSE PIN(96), 150               '1/4 hr Chime on
   print "Chime 1 ON"
  endif

IF (Minutes = 0) AND (Seconds = 0) AND (HourFlag = 0) THEN
  HourFlag = (Hours mod 12) + 1    '+1 used to stop midday from multiple triggering
  SETTICK 4400, HourChime, 2       'Using tick 2 as hourly chime delay
  IF HourFlag = 1 THEN
    PULSE middayPin, 150           'Play the midday chime
    print "Midday Pin"
  ELSE
    HourChime                      'Play first hourly chime
  ENDIF
ENDIF

LOOP
END

SUB HourChime
  HourFlag = HourFlag - 1          'count them down
  IF HourFlag = 0 THEN             'If we just played the last one needed
    SETTICK 0,,2                   'then reset the tick we were using
  ELSE
    PULSE hourPin, 150             'Play the hourly chime
    print "Chime on"
  ENDIF
END SUB


It prints the chime on the display when the 1/4 hour arrives
but
PULSE PIN(96), 150 does not turn the sound board on, it doesn't seem to be pulling the pin low which is what's needed

IF I manually pull the pin low using a wire to ground then the board plays the correct chime

Also the hour function isn't working at the moment, I'll go back to that after I figure out the 1/4ly chimes

I can't find PULSE in either of the manuals?


EDIT:
Got the Quarters working by using this code

IF Val(Mid$(Time$,4,2)) > = 07 and IF Val(Mid$(Time$,4,2)) < = 22 THEN
  IF Val(Mid$(Time$,4,2)) = 00 and Val(right$(Time$,2)) = 00 then
   SETTICK 150, SecsChime, 2       'Using tick 2 as hourly chime delay   
    PIN(92) = 0
  endif
  IF Val(Mid$(Time$,4,2)) = 15 and Val(right$(Time$,2)) = 00 then
   SETTICK 150, SecsChime, 2       'Using tick 2 as hourly chime delay   
    PIN(97) = 0
  endif

  IF Val(Mid$(Time$,4,2)) = 30 and Val(right$(Time$,2)) = 00 then
   SETTICK 150, SecsChime, 2       'Using tick 2 as hourly chime delay   
    PIN(96) = 0
  endif

 IF Val(Mid$(Time$,4,2)) = 45 and Val(right$(Time$,2)) = 00 then
   SETTICK 150, SecsChime, 2       'Using tick 2 as hourly chime delay   
    PIN(95) = 0
  endif

SUB SecsChime
PIN(97) = 1
PIN(96) = 1
PIN(95) = 1
PIN(92) = 1
SETTICK 0,,2
END SUB


Edited by lew247 on 05 January 2018 at 11:29pm
Back to Top View lew247's Profile Search for other posts by lew247
 
Azure
Guru
Guru
Avatar

Joined: 09 November 2017
Location: Australia
Online Status: Offline
Posts: 300
Posted: 06 January 2018 at 12:42am | IP Logged Quote Azure

Pulse is on page 58 of the MicroMite MMBASIC User Manual.

I not sure why you changed the CONST and PULSE syntax I typed, it is now incorrect.

Here are the corrected lines that need to be changed:

CONST middayPin = 90
CONST hourPin = 91

'Remove the Hours, Minutes and Seconds lines at the top

PULSE 96, 150

IF (Val(Mid$(Time$,4,2)) = 0) AND (Val(right$(Time$,2)) = 0) AND (HourFlag = 0) THEN


Also the first line of your quarters code above has 2 IF on the first line.
The second one should not be there.

The chime silent time can be added using another IF once it is all working.
Back to Top View Azure's Profile Search for other posts by Azure
 


<< Prev Page of 34 Next >>
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1563 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.16