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
Author
Message << Prev Topic | Next Topic >>
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 972
Posted: 06 January 2018 at 3:36am | IP Logged Quote lew247

I found it thanks
You can also create a pulse using the PULSE command. This will generate very narrow pulses (eg, 20s) or
long pulses up to several days. Long pulses are run in the background and the program will continue
uninterrupted

trying it now

Edited by lew247 on 06 January 2018 at 3:44am



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: 972
Posted: 14 March 2018 at 9:53pm | IP Logged Quote lew247

I'm stuck again
I want to update the Micromite clock with the time coming from the internet via an ESP8266
I have the code for the ESP and updating the clock working
I'm stuck on how to do it

I'd like to update the clock the FIRST time that COM2 receives data but not any of the other times

I have
TIME$ = tim2$              'Update Micromite clock
which works and tim2$ is the correct time from the ESP8266

How do I run this just once the first time COM2 gets data and not every time it does?
The problem being the Micromite might not get the data from the ESP8266 for up to 20 seconds after it boots up and then transmits the data every 15 seconds
I don't want the clock updating so often ***unless it won't do any harm***
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: 972
Posted: 15 March 2018 at 1:01am | IP Logged Quote lew247

Alternatively
Does anyone know why this only works SOMETIMES?

[CODE]tim$ = FieldArray$(18) 'time from ESP2866/ntp SERVER
tim2$ = mid$(tim$,12,8) 'Curent time ready to send to Micromite or RTC
print TIME2$
TIME$ = tim2$ [/CODE}

Some of the time it works
other times randomly it comes up with the error
Quote:
[187] Time$ = tim2$ 'update Micromite clock
Error: Syntax


The string received from the ESP866 is

7.23,04d,10.19,997,5.1,130,62,8.35,11,96,10000,broken clouds,Clouds,987.64,1.72,7.11,8.39,Rain,Wed Mar 14 14:55:47 2018 ,*

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

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 6158
Posted: 15 March 2018 at 7:12am | IP Logged Quote Grogster

Syntax error because the string you are trying to ram down the throat of TIME$ is not in the format that MMBASIC wants.

Your example is taking the 8 characters in tim$ from the LEFT of the string, so you are trying to pass ".19,997," to TIME$, and it throws a wobbly.

Try this:

TIME$=MID$(tim2$,LEN(tim2$)-15,8)

That should extract the 8 bytes of the time from tim2$, and that SHOULD be in the format that TIME$ wants. Assuming that the time and date are ALWAYS on the end of the string and in the same format, then it won't matter what length the string is, as the above will always correctly extract the data from the end of the string.

To check this ONCE only, then use a flag along the lines of:


IF TIMEFLAG=0 THEN
  TIME$=MID$(tim2$,LEN(tim2$)-15,8)
  TIMEFLAG=1
ENDIF


When this runs, it will check the flag, and if it is clear, it will extract the time and pass it to the system clock. If the flag IS set, it will ignore that code(IE: not set the clock) and continue with the next line of code.

Untested, but should work.



Edited by Grogster on 15 March 2018 at 7:20am


__________________
Smoke makes things work. When the smoke gets out, it stops!
Back to Top View Grogster's Profile Search for other posts by Grogster Visit Grogster's Homepage
 
Paul_L
Guru
Guru


Joined: 03 March 2016
Location: United States
Online Status: Offline
Posts: 401
Posted: 15 March 2018 at 7:25am | IP Logged Quote Paul_L

Hi Lou,

The received data string is
7.23,04d,10.19,997,5.1,130,62,8.35,11,96,10000,broken clouds,Clouds,987.64,1.72,7.11,8.39,Rain,Wed Mar 14 14:55:47 2018 ,*

It looks to me like this line
tim2$ = mid$(tim$,12,8) 'Curent time ready to send to Micromite or RTC
sets tim2$ to ".19,997,"

But the syntax needed is TIME$="HH:MM:SS" or "HH:MM" or "HH" and ".19,997" doesn't fit.

I'm not sure how the data string above is formatted but if the hour is "10" and the minute is "19" try this.

tim2$ = mid$(tim$,10,2) + ":" + mid$(tim$,13,2)
which gives you "10:19"

If the hour is "04", the minute is "10" and the seconds are "19" then try this.

tim2$ = mid$(tim$,6,2) + ":" + mid$(tim$,10,2) + ":" + mid$(tim$,13,2)
which gives you "04:10:19"

Paul in NY

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


Joined: 03 March 2016
Location: United States
Online Status: Offline
Posts: 401
Posted: 15 March 2018 at 7:27am | IP Logged Quote Paul_L

Hi Grogs, you type faster than I do! Paul.
Back to Top View Paul_L's Profile Search for other posts by Paul_L
 
TassyJim
Guru
Guru
Avatar

Joined: 07 August 2011
Location: Australia
Online Status: Offline
Posts: 2686
Posted: 15 March 2018 at 7:42am | IP Logged Quote TassyJim

tim$ = FieldArray$(18) extracts the 18th field from the data. 19th if you start from zero.

Is it always the 18th field that has the time?

In the example field 18 is "Wed Mar 14 14:55:47"

Is it always the same size with 2 digits for the date?

PRINT tim$ and tim2$ for debug purposes.

Jim

__________________
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm
Back to Top View TassyJim's Profile Search for other posts by TassyJim Visit TassyJim's Homepage
 
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 972
Posted: 16 March 2018 at 3:59am | IP Logged Quote lew247

Thanks everyone
I've made it easier
Now the time comes in on the 18th field and is in the format hour:min:sec
So it can be directly passed to the Micromite and it works

The question for today is

I have the ESP8266 transmitting the weather data including the time once every 15 seconds

HOW can I get the Micromite to ONLY update the time once an hour?
Preferably at the top of each hour say when Min = 00 and Secs = 00

The problem I have is I have no idea and cannot control the exact time the ESP sends the data and it sends the data up to 4 times a minute and at the moment is updating the Micromite each time it updates.

EDIT:
This is the relevant section of code for the MM

tt1$ = FieldArray$(18)                                                     'hour:min:sec
dow1$ = FieldArray$(19)  'Day of week (example) Thu
dm1$ = FieldArray$(20)   'day:month (example) in 15:03
Year$ = FieldArray$(21) 'Year  (example) 2018
Month$ = right$(dm1$,3)  'Month
Day$ = dow1$   'Day of week


Edited by lew247 on 16 March 2018 at 4:03am
Back to Top View lew247's Profile Search for other posts by lew247
 
TassyJim
Guru
Guru
Avatar

Joined: 07 August 2011
Location: Australia
Online Status: Offline
Posts: 2686
Posted: 16 March 2018 at 6:25am | IP Logged Quote TassyJim

Quote:
DIM oldHour$ ' a new variable for saving the old time


tt1$ = FieldArray$(
18) 'hour:min:sec
IF LEFT$(tt1$,2) <> oldHour$ THEN ' we are into a new hour
TIME$ = tt1$ ' set the time
oldHour$ = LEFT$(tt1$,2) ' set the oldHour so we don't do anything until the next hour
ENDIF



The variable oldHour$ will be "", so different to the real hour the first time the program is run.
After the first run, it will only be different at the start of a new hour so the time is updated once per hour.

Jim

__________________
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm
Back to Top View TassyJim's Profile Search for other posts by TassyJim Visit TassyJim's Homepage
 
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 972
Posted: 16 March 2018 at 7:14am | IP Logged Quote lew247

Thank you so much, I've spent hours trying to work out a way to do that and you did it in minutes
Back to Top View lew247's Profile Search for other posts by lew247
 


If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Search the forums using Google.
<< Prev Page of 34
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.1406 seconds.
Privacy Policy     Process times : 0.03, 0, 0, 0.11