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

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 790
Posted: 12 March 2016 at 9:09pm | IP Logged Quote lew247

What is COM1: ENABLE ?



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

Joined: 20 June 2011
Location: Australia
Online Status: Offline
Posts: 1967
Posted: 12 March 2016 at 11:33pm | IP Logged Quote bigmik

Hi Lew,

The enable is for use with RS485 operation which `can' use an enable pin..

You can safely ignore this for your RS232 work.

From memory it goes high when the TX wants to talk this goes to the enable pin on a RS485 driver chip.

The main use is it is possible to have multiple `slaves' on the same daisy chained line and they all listen and when they have something to say they can enable the TX line of the RS485 driver to send information back to the Master..

ie. They can all listen 100% of the time but only one can talk at a time.. Usually this is controlled by a POLLed protocol, the MASTER asks address 1 do you have something to send and waits, if no response after a set time then the MASTER asks address 2 do you have.... Etc etc..

Regards,

Mick

__________________
Mick's uMite Stuff can be found HERE

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

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 790
Posted: 13 July 2016 at 4:39pm | IP Logged Quote lew247

I'm stuck again

I want to print this
PRINT #2,Line2$,Line1$,wheading,wSpeed,wgust,hgust,mmrain,mmrain2,bme280_read_temp,bme280_read_pressure,hightemp,hightemp2,low temp,lowtemp2,bme280_read_humidity,UVindex,lux
to COM1 which I have enabled and it's working but it will not print to the com port.


print " Direction:    ";STR$(wheading,3,2);" Degrees" 
print " WindSpeed:    ";STR$(wSpeed,3,2); " MPH"
print " Gust          ";STR$(wgust,3,2); " MPH"
print " Highest Gust  ";STR$(hgust,3,2); " MPH"
print " Rain Today    ";STR$(mmrain,3,2);" mm"
print " Rain Yesterday";STR$(mmrain2,3,2);" mm"
print " Temperature   "; STR$(bme280_read_temp(),3,2)" C "
print " Pressure      "; STR$(bme280_read_pressure(),3,2)" mB " 
PRINT " Highest Temp  ";STR$(hightemp) " C"
PRINT " Hi Temp Yesterday ";STR$(hightemp2) " C"
PRINT " Lowest Temp   ";STR$(lowtemp) " C"
PRINT " LOW Temp Yesterday ";STR$(lowtemp2) " C"
PRINT " HUMIDITY      "; bme280_read_humidity()"%" 
print " UV Index:     ",STR$(UVindex,3,2) 
Print " Light         ";STR$(lux,3,2);" LUX"


Error: A sub/fun has the same name: BME280_READ_TEMP

I've tried it with $ at the end of the name, I've tried it with brackets around it, and with $and brackets, but I cannot figure out what it doesn't like

IF I try and print Line2$,Line1$,wheading,wSpeed,wgust,hgust,mmrain,mmrain2 it works
it fails when I put the rest of the line in

EDIT:
I even tried this and it failed
PRINT #2, STR$(bme280_read_pressure),STR$(bme280_read_temp),STR$(bme280_read_humidity)

Error: A sub/fun has the same name: BME280_READ_PRESSURE

I don't get why it fails when it will print to the console quite happily

EDIT 2:
I got it working by making 3 new "names" (variables?)
called temp, humidity and pressure
then did pressure = bme280_read_pressure, temp = bme280_read_temp and humidity = bme280_read_humidity
Then
PRINT #2, temp, pressure, humidity works

I also found out I need to put a "," between them so I can sort them on the indoor unit

I bet there is a much simpler and quicker way to do this, but I've no idea what it is

Edited by lew247 on 13 July 2016 at 5:36pm
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: 790
Posted: 25 July 2016 at 7:07pm | IP Logged Quote lew247

Back again with another question, which to me is hard but to others is probably simple/

I know how to get a specific result from a ?string"
an example is extracting the time from the $GPRMC a GPS

Is there a way to IGNORE the WHOLE string IF a part of the result includes "not found"

I want to do something, but ocassionally the result is the word "not found" instead of what I actually want.
This can or could happen at any of the parts I want to extract.

IF it was only in one position it "might" occur then I could obviously tell the MM to ignore it, but is there an "EASY" way to tell MM to ignore the whole string if any part of it contains the word "not found" ?

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


Joined: 05 April 2013
Location: United Kingdom
Online Status: Offline
Posts: 2436
Posted: 25 July 2016 at 7:17pm | IP Logged Quote WhiteWizzard

@lew247

Look at using the INSTR function.
Something like:

IF INSTR(GPS-In$,"not found")=0 THEN
   'do your normal stuff here as GPS-In$ doesn't contain 'not found'
ELSE
   'invalid data so do whatever
ENDIF


Hope this gives you an idea for proceeding

WW

EDIT: You may need to be careful of case sensitivity with 'Not Found', 'NOT FOUND', 'not found' etc

Edited by WhiteWizzard on 25 July 2016 at 7:19pm


__________________
For everything MicroMite visit MicroMite.org

Direct Email: WhiteWizzard@MicroMite.org
Back to Top View WhiteWizzard's Profile Search for other posts by WhiteWizzard Visit WhiteWizzard's Homepage
 
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 790
Posted: 25 July 2016 at 7:22pm | IP Logged Quote lew247

Thanks Phil, I had no idea there was an ISTR function, I was looking in the command list
That's a great help, I should be able to do what I want now
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: 790
Posted: 15 August 2016 at 10:50am | IP Logged Quote lew247

Can anyone tell me WHY the voltage is being rounded up?

The code
DIM integer Batt2
DIM INTEGER BATT3
DIM INTEGER BATT
Batt2 = Pin(24)
Batt3 = Batt2 * 2
batt = Batt3
temp = tempr(3)
PRINT" Battery Voltage "; STR$(Pin(24))
PRINT " Battery Voltage ";STR$(batt);" V" 
PRINT" Battery Voltage "; STR$(batt2);" V"
PRINT" Battery Voltage "; STR$(batt3);" V"


The printout{quote] Battery Voltage 1.78065
Battery Voltage 4 V
Battery Voltage 2 V
Battery Voltage 4 V[/quote]


Edited by lew247 on 15 August 2016 at 10:50am
Back to Top View lew247's Profile Search for other posts by lew247
 
WhiteWizzard
Guru
Guru


Joined: 05 April 2013
Location: United Kingdom
Online Status: Offline
Posts: 2436
Posted: 15 August 2016 at 10:54am | IP Logged Quote WhiteWizzard

Hi Lewis,

An integer has no decimal places. So 1.78065 is rounded up to the integer value of 2.

So Batt2 (integer) reads the pin and saves value of 2.
Batt3 = 2 * 2 (=4)
And hence Batt = Batt3 = 4

WW


__________________
For everything MicroMite visit MicroMite.org

Direct Email: WhiteWizzard@MicroMite.org
Back to Top View WhiteWizzard's Profile Search for other posts by WhiteWizzard Visit WhiteWizzard's Homepage
 
WhiteWizzard
Guru
Guru


Joined: 05 April 2013
Location: United Kingdom
Online Status: Offline
Posts: 2436
Posted: 15 August 2016 at 10:55am | IP Logged Quote WhiteWizzard

Sorry - forgot to mention; IF you change all three DIMs from INTEGER to FLOAT then you will get the decimal places.
Then use STR$ with the optional parameters to display the number of decimal places required

WW

__________________
For everything MicroMite visit MicroMite.org

Direct Email: WhiteWizzard@MicroMite.org
Back to Top View WhiteWizzard's Profile Search for other posts by WhiteWizzard Visit WhiteWizzard's Homepage
 
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 790
Posted: 15 August 2016 at 10:59am | IP Logged Quote lew247

Thanks WW
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: 790
Posted: 15 August 2016 at 12:18pm | IP Logged Quote lew247

Another question

How can I do this?

If LOC(#3)<>0 then LOOP
If LOC(#2)<>0 then LOOP

The way I understand it is - if location 3 is empty it loops therefore not checking location 2

I'd like the program to keep checking both com ports while carrying on with the program and if it finds anything then come out of the respective loop into a sub
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: 5166
Posted: 15 August 2016 at 12:29pm | IP Logged Quote Grogster

Assuming you want to check #3 then #2, then you could do something like:


Do
  If LOC(#3)<>0 then
  D$=INPUT$(LOC(#3),#3) 'Suck everything out of buffer so it is empty for next time
    ----- YOUR #3 code you want to happen if there is something in the buffer goes here -----
  ENDIF
  If LOC(#2)<>0 then
    D$=INPUT$(LOC(#2),#2)
    ----- YOUR #2 code you want to happen if there is something in the buffer goes here -----
  ENDIF
LOOP


That will go around in circles checking each COM port buffer, and then doing whatever needs to be done within the main DO/LOOP as it detects each one.

Provided the com port buffers are not time critical, it will deal with the data from handle #3 first, then handle #2 next.

This should do what you want, but I might have misunderstood how you want the code to flow.......

Edited by Grogster on 15 August 2016 at 12:30pm


__________________
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
 


<< Prev Page of 33 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.1250 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.12