Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 03:43 17 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 : MM Edit update V3.5.5 with MicroMite MK2

Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 06:29pm 27 Oct 2014
Copy link to clipboard 
Print this post

I have updated MM Edit to include MicroMite MK2 syntax.
Other recent changes are:
Auto backups
TCPIP connections including a test micromite (MK2) accessible via thew net.
Remembers the last 10 connections to make it easier when you have multiple devices
Because of the updates to the syntax files, you need to download the full program
http://www.c-com.com.au/MMedit.htm

The test micromite is now running MM Basic V4.6beta on a 28 pin MX170
There is a BMP085 on the I2C and a DHT22 on pin 26.
In MMEdit, connect to the test server or in TeraTerm connect to tassyjim.ddns.net port 3002
I log IP addresses and the data uploaded to the micromite for quality control.
If you upload any code, remember that it is in public view.

This is the code running on it (until someone changes it):

' reading the BMP085 pressure and DHT22 humidity sensors
' TassyJim 28 Oct 2014

DHT22pin = 26 ' 3.3V pins are OK for short leads <1 metre

DIM BMPData(2) ' store data from BMP085
DIM cal(11) ' calibration data
oss = 0 ' over sampling 0 to 3
alt = 240 ' your altitude in metres

BMP085calMEM = &HAA ' start of 11 calibration values
BMP085address = &H77 ' BMP085 address
BMP085control = &HF4 ' BMP085 control register
BMP085temp = &H2E ' BMP085 temperature command
BMP085pres = &H34 ' BMP085 pressure command
BMP085pres = BMP085pres + oss*&H40 ' adjust command for oversampling
BMP085reading = &HF6 ' register for results of reading

I2C OPEN 400, 200 ' Enable I2C. use slow speeds for long leads
PAUSE 20
z = Calibrate() ' read the calibration data
SETTICK 30000, doread
PAUSE 1000
doread

DO
LOOP
END

SUB doread
readhumidity
t=temperature()
p=pressure(oss)
p0=Psl(p,alt)
PRINT TIME$;" T(BMP085):";STR$(t,3,1);" P(sl):";STR$(p0/100,5,1);
PRINT " T(DHT22): " STR$(TEMP,3,1);" H:" STR$(HUMID,3,1)
PAUSE (30000) ' delay 30 seconds between readings
END SUB

FUNCTION Calibrate()
' needs to be called once for each module.
' safest to do it on every program start.
LOCAL n, calMEM
calMEM= BMP085calMEM
FOR n = 1 TO 11
I2C WRITE BMP085address, 0, 1, calMEM ' first calibration location
PAUSE 1
I2C READ BMP085address, 0, 2, BMPData(0)
'print BMPData(1), BMPData(0)*256 + BMPData(1)
cal(n) = BMPData(0)*256 + BMPData(1)
IF n < 4 OR n > 6 THEN ' need to convert some to signed numbers
IF cal(n) > 32767 THEN
cal(n) = cal(n) - 65536
ENDIF
ENDIF
'print n,cal(n)
PAUSE 1
calMEM=calMEM+2 ' advance to the next calibration location
NEXT n
END FUNCTION

FUNCTION temperature()
' returns the temperature in degrees C to one decimal place
LOCAL UT, x1, x2, b5
I2C WRITE BMP085address, 0, 2, BMP085control, BMP085temp
PAUSE 5
I2C WRITE BMP085address, 0, 1, BMP085reading
I2C READ BMP085address, 0, 2, BMPData(0)
UT = BMPData(0)*256 + BMPData(1)
'calculate true temperature
x1= INT( (UT-cal(6))*cal(5)/32768)
x2=INT( cal(10)*2048/(x1+cal(11)))
b5=x1+x2
temperature = INT((b5+8)/16)/10
END FUNCTION

FUNCTION pressure(oss)
' returns the pressure in pascals. Divide by 100 for millibars
' recalculates the temperatre.
' time could be saved by reading the temperature once evry 10 minutes
' when taking readings at short intervals
LOCAL UT, UP, x1, x2, x3, b5, b6, b7, pres, p
pres = BMP085pres + oss*&H40
I2C WRITE BMP085address, 0, 2, BMP085control, BMP085temp
PAUSE 5
I2C WRITE BMP085address, 0, 1, BMP085reading
I2C READ BMP085address, 0, 2, BMPData(0)
UT = BMPData(0)*256 + BMPData(1)
I2C WRITE BMP085address, 0, 2, BMP085control, pres
IF oss = 0 THEN ' different oversampling requires different
PAUSE 5 ' reading times
ELSEIF oss = 1 THEN
PAUSE 8
ELSEIF oss = 2 THEN
PAUSE 14
ELSE
PAUSE 26
ENDIF
I2C WRITE BMP085address, 0, 1, BMP085reading
I2C READ BMP085address, 0, 2, BMPData(0)
UP = BMPData(0)*256 + BMPData(1)
I2C WRITE BMP085address, 0, 1, BMP085reading+2
I2C READ BMP085address, 0, 1, BMPData(0)
UP=(UP*256+BMPData(0))/2^(8-oss)
'calculate true temperature
x1= INT( (UT-cal(6))*cal(5)/32768)
x2=INT( cal(10)*2048/(x1+cal(11)))
b5=x1+x2
t=INT((b5+8)/16)/10
'print "Temperature: ",t
'calculate true atmospheric pressure
b6 = b5 - 4000
x1 = INT((cal(8)*(b6*b6/4096))/2048)
x2 = INT(cal(2)*b6/2048)
x3 = x1 + x2
b3 = INT(((cal(1)*4+x3)*2^oss +2)/4)
x1 = INT(cal(3)*b6/8192)
x2 = INT((cal(7)*(b6*b6/4096))/65536)
x3 = INT(((x1+x2)+2)/4)
b4 = INT(cal(4)*x3/32768+cal(4))
b7 = INT((UP - b3)*(50000/2^oss))
p = INT((b7*2)/b4)
x1 = INT(INT(p/256)*INT(p/256))
x1 = INT((x1*3038)/65536)
x2 = INT((-7357*p)/65536)
pressure = INT(p+(x1 + x2 + 3791)/16)
END FUNCTION

FUNCTION Psl(p, alt)
'given local pressure and altitude, returns pressure at sea level
Psl= p/(1-alt/44330)^5.255
END FUNCTION

FUNCTION uFormat$(x,p)
' given a number (x) and the required number of decimal places (p)
' returns formatted string. Negative and zero p is permitted
LOCAL f$
f$=STR$(CINT(x*10^p))
IF LEN(f$)<=p THEN
f$=STRING$(p+1-LEN(f$), "0")+f$
ENDIF
IF p>0 THEN
uFormat$=LEFT$(f$,LEN(f$)-p)+"."+RIGHT$(f$,p)
ELSEIF p = 0 THEN
uFormat$=f$
ELSE
uFormat$=f$+STRING$(ABS(p),"0")
ENDIF
END FUNCTION

FUNCTION myAlt(p, p0)
' given local pressure (p) and pressure at sea level (p0)
' returns altitude in metres
myAlt = 44330*(1-(p/p0)^0.1903)
END FUNCTION

SUB readhumidity
DHT22 DHT22pin, TEMP, HUMID ' dump stale reading
PAUSE 2000 ' time for the sensor to complete next read
DHT22 DHT22pin, TEMP, HUMID ' this reading is only 2 seconds old
'PRINT TIME$;" Temperature: " STR$(TEMP,3,1);" Humidity: " STR$(HUMID,3,1)
END SUB


As always, please let me know about any problems with MMEdit including errors in the manual.

Jim
VK7JH
MMedit   MMBasic Help
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 02:49am 06 Nov 2014
Copy link to clipboard 
Print this post

Hi folks.

Not having any luck with the last couple of versions of MMEdit.
Jim - can you please confirm for me, that MMEdit is compatible with Windows 8.1 64-bit?

Since Microsoft updated my PC to 8.1, MMEdit has been really unstable.
How unstable?

- Often fails to start - comes up with DLL error, and previous code and settings are not auto-loaded.

- 99% of the time, MM talk won't connect to MM, even though correct port selected.

- If you accidentally forget to set the correct port, and pick the wrong one, then call MM File, MMEdit locks up. You can't close the MM File window, and you can't close the main MMEdit window. I have to kill it in Task Manager.

- If I manage to program the MM(1 out of 5 attempts works on average), MMEdit seems to hold onto the serial port - it does not close it when MM File is finished, so: (1) Open MM File(if it will), and send a file to the MM. [OK] (2) Close the MM File window when "All done!" shows up. [OK] (3) Make some change to the code, then go back to MM File. [FAIL] - Comes up with "The device is already open"

Tomorrow, I will see if I can dig out an old XP machine and see if MMEdit wants to run on that. I actually suspect Windoze at the moment, but I thought I would post this report, as I hoped that perhaps the latest version of MMEdit might have fixed this issue IF IT WAS A BUG, but it does not seem to be.
Smoke makes things work. When the smoke gets out, it stops!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 11:32am 06 Nov 2014
Copy link to clipboard 
Print this post

I normally use Windows 7 but I do test MMEdit on W8.1 64 bit and have not seen the problems you are describing.

I would like a copy of the Configuration Report and Error log, both available from the Help menu.
Also a copy of mru.inf and locate.inf for the data folder. The location of the data folder can be found from Help/About.

Then you can try a full uninstall and reinstall.
Uninstall MMEdit
delete every thing in the Data folder
reboot
then reinstall.
You can send the info to the contact address in Help/About.

What device do you have trouble with micromite, maximite or both?
What make/version of USB-TTL converters are you using?
I might have the same ones here to test with.
Are you connecting direct to the PC or via a USB hub?
What antivirus do you use?

Some people have had problems with the drivers for the maximite but once again, I have not seen any problems.

There was a big update to W8.1 recently. It would be worth manually checking Window Update to see if there are any updates but be wary of the FTDI driver update.

Jim


VK7JH
MMedit   MMBasic Help
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 12:28pm 06 Nov 2014
Copy link to clipboard 
Print this post

One other point I should mention.
I have said it before and it's in the manual but it deserves repeating.

If you have problems with your connection to the maximite, Windows is likely to get confused.
To re-enable the connection:
Close your terminal program. With recent versions of MMEdit it should be OK to just close the File and Chat windows.
Unplug the maximite/USB-TTL converter.
Wait for the OK sound.
Reinsert the maximite.
Wait for the OK sound.
Restart you terminal program.

If you unplug and reinsert the maximite with the terminal program still running, the maximite will not communicate.

USB takes time to notify Windows when changes occur so allow plenty of time between unplugging and reinserting.

I spent a lot of time trying to reliably detect the inserts etc but the microchip drivers don't make it easy so I gave up.

Jim

VK7JH
MMedit   MMBasic Help
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 01:14pm 06 Nov 2014
Copy link to clipboard 
Print this post

Hi Jim - thanks for your reply.

To answer some questions:

- I can open config log, but not error log - nothing happens when I select it from the menu.

What device do you have trouble with micromite, maximite or both? - BOTH

What make/version of USB-TTL converters are you using? - HOME BREW BASED ON MAX202(for MicroMite) - no cheap chinese cable. When using the 202 adaptor, this connects to a legacy serial port - COM1, so no USB involved at all for MicroMite programming. Although I still have issues connecting to uM chips too, it is far less of a problem with these chips then with the USB-based MaxiMite.

Are you connecting direct to the PC or via a USB hub? - DIRECT

What antivirus do you use? - Windows Defender, auto-updated, nightly scans.

I will send the files to your email shortly.Edited by Grogster 2014-11-07
Smoke makes things work. When the smoke gets out, it stops!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 02:55pm 06 Nov 2014
Copy link to clipboard 
Print this post

Can you resend the inf files but either change the extension to .txt or zip them up.
Outlook refuses to let me look at files it doesn't like.

Not being able to open the error log means that it is empty. I must put a message in to inform the user of this.

I use Windows Defender on my W8.1 PC so we should be able to rule that out.
The AV I used to use would silently delete files it didn't like which caused interesting problems.

I haven't used a legacy serial port - none of my laptops have one!

There has been a Beta update for Liberty Basic (the program that MMEdit is written in) released today so I will give it a try. There have been a few changes to suit W8 but the only obvious one that helps me is the ability to set higher baud rates.

Are you able to use 'load and run' instead of 'file manager'?
Most of the work in recent updates has been with 'load and run' and timing to suit micromites.

Jim
VK7JH
MMedit   MMBasic Help
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 03:09pm 06 Nov 2014
Copy link to clipboard 
Print this post

Hi Jim - will resend renamed files. I never use load-and-run, so will try that with some test code - perhaps it is as simple as that, where the MicroMite chips are concerned....

Stay tuned.
Smoke makes things work. When the smoke gets out, it stops!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 09:12pm 06 Nov 2014
Copy link to clipboard 
Print this post

The only thing I can see in your configuration is the Edit mode delay which is set to 150.
I would try increasing that to 300.
Even though it's called Edit mode delay, it is used for a lot of other delays as well.

You might want to try another update. It uses the beta version of Liberty Basic and I have not had time to do a lot of testing but it seems OK.
The only change to MMEdit is you can now set 230800 as the baud rate.
I also fixed a problem where an extra cr was being sent sometimes (actually a lf but MM Basic treated it as a cr.

The updated files are here;
http://www.c-com.com.au/stuff/MMedit_b.zip

There are two files which need to be placed in the program folder.

Please try the Edit mode delay setting of 300 before upgrading to see if that fixes things.
Also, if 'load and run' is better than the file manager will help locate the cause of the problems.

Jim



VK7JH
MMedit   MMBasic Help
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9078
Posted: 11:49pm 06 Nov 2014
Copy link to clipboard 
Print this post

Wilco.

I will post a report tomorrow once I have played with it.
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


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

© JAQ Software 2024