Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:02 04 Jul 2025 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 : Micromite MkII beta testers needed

     Page 4 of 8    
Author Message
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 327
Posted: 01:53pm 29 Oct 2014
Copy link to clipboard 
Print this post


I read this in the CHANGE LOG:
  Quote  When used to read pin 0 the PIN() function will measure the voltage of the internal voltage reference (nominally 1.2V). Note that pin 0 does not have to be configured via SETPIN.

So, I decided to give it a try... When I type PRINT PIN(0) the Micromite displays power on message. Am I doing something wrong?


--Curtis

FYI - I'm using a 28 pin chip.
I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6268
Posted: 02:33pm 29 Oct 2014
Copy link to clipboard 
Print this post

  Grogster said   Can someone please clarify the new variable arrangement for me.

Not requiring $ for a string variable anymore, does this mean that you can have:

A=1234 for a numeric variable
A="1234" for a string variable, dropping the $

A=1234 for number and A$="1234" for a string are much easier for ME to follow, as I am sure, many other old-school programmers. However, I don't mind the change, so long as I understand that change - which I might not!


You can still use the $ for strings so there is no need to retrain.

Some languages prefer to declare all variables and determine their type when they are declared.
I will probably stick to strings with $ for MMBasic although I do go without them in other languages.
As your programs get bigger, options like declaring variables before use are very useful.

Jim

VK7JH
MMedit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6268
Posted: 02:36pm 29 Oct 2014
Copy link to clipboard 
Print this post

  Justplayin said  
I read this in the CHANGE LOG:
  Quote  When used to read pin 0 the PIN() function will measure the voltage of the internal voltage reference (nominally 1.2V). Note that pin 0 does not have to be configured via SETPIN.

So, I decided to give it a try... When I type PRINT PIN(0) the Micromite displays power on message. Am I doing something wrong?


--Curtis

FYI - I'm using a 28 pin chip.


Worked OK for me.
28 pin Beta16

Jim
VK7JH
MMedit
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 03:13pm 29 Oct 2014
Copy link to clipboard 
Print this post

@Grogster - To clear up the mechanism for declaring the type of a variable...

You can set the type of a variable in a number of ways:

name$ = "Grogs"
This is the old method (still supported) where the variable is automatically created and the $ suffix specifies that it is a string. Automatic creation of variables can cause some nasty bugs so if you do not want this you can use OPTION EXPLICIT.

DIM name$
name$ = "Grogs"
In this case the variable is explicitly declared and you use the $ suffix to specify that it is a string. Note that you will also need to use the $ suffix whenever you refer to the variable in your program.

DIM STRING name
name = "Grogs"
In this case the type is specified in the declaration and the suffix is not needed (although you can still use it if you want). This is the preferred way of doing it as it leads to fewer bugs.

DIM name AS STRING
name = "Grogs"
This is the way that Microsoft does it in Visual Basic and you can use the same syntax in MMBasic.

When you specifically set the type of the variable in the declaration MMBasic will then know its type and will prevent misuse of the variable, even if it does not have a suffix. For example:
> list
DIM STRING name
name = 1234
>
> RUN
[2] name = 1234
Error: Expected a string
>


With the larger memory space in the Micromite MkII people will be writing more complex programs with more chances of creating bugs. These changes have been implemented to make it easier to write bug free programs. However, you can still use the old methods which are OK for quick and dirty programs.

Geoff
Geoff Graham - http://geoffg.net
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9586
Posted: 03:18pm 29 Oct 2014
Copy link to clipboard 
Print this post

Excellent, thanks Geoff. That explains it perfectly, and I can see the need for it, and the reasons behind it for helping to minimize bugs.
Smoke makes things work. When the smoke gets out, it stops!
 
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 327
Posted: 03:27pm 29 Oct 2014
Copy link to clipboard 
Print this post

Okay... I have been testing programs on the Micromite for several hours and all was fine until the Pin(0) reset problem. Since it worked for TassyJim I rechecked my breadboard setup and found a missing jumper wire. I must have pulled it out by mistake after doing one of the hardware tests. I also switched from using the USB adapter for power to a separate 3.3v power supply. It still does the same thing. I'll have to flash another chip and see what happens with it.


--Curtis
I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 437
Posted: 09:18pm 29 Oct 2014
Copy link to clipboard 
Print this post

Pull up/ down works fine.
I have also the pin 1 reset on Mk2
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 09:18pm 29 Oct 2014
Copy link to clipboard 
Print this post

  robert.rozee said  can you possibly expand a little on the +/-20%? (sleep time inaccuracy)
i'm hoping it is actually more like (+/-1sec) + (+/-0.5%)

The sleep timer uses the LPRC oscillator which Microchip says is +/- 15% plus there are other inaccuracies. The SLEEP command was never intended for accurate timing, if accuracy is important you should use an external RTC with an alarm output connected to the WAKEUP pin.

Geoff
Geoff Graham - http://geoffg.net
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2428
Posted: 03:20am 30 Oct 2014
Copy link to clipboard 
Print this post

  Geoffg said  
The sleep timer uses the LPRC oscillator which Microchip says is +/- 15% plus there are other inaccuracies. The SLEEP command was never intended for accurate timing, if accuracy is important you should use an external RTC with an alarm output connected to the WAKEUP pin.
Geoff


the application i have in mind is an intervalometer, where a small amount of drift is ok. if the drift characteristics are mostly determined by temperature and supply voltage changes (suggested as contributing factors in the datasheet), then one could perhaps compensate for these - over a limited range a simple linear approximation would probably do. pushing drift down to +/-2% would be quite acceptable. an LM555 could likely achieve this.

would it be practical/easy for the on-die temperature sensor to be made accessible within MMbasic? along with the per-second increment applied to TIMER after waking up? (maybe as MM.LPRC which has a default value of 1000)

being able to read the on-die temperature sensor voltage would also enable compensating for ADC drift for the analog pins as well. perhaps accessing it as on_chip_temp = PIN(-1) could be used?

largely just me musing here at 2am in the morning.


rob :-)
 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 437
Posted: 04:13am 31 Oct 2014
Copy link to clipboard 
Print this post

a reset solved my question so i delete my message it contains no info for others.Edited by plasma 2014-11-01
 
Synergetic

Newbie

Joined: 14/01/2013
Location: New Zealand
Posts: 22
Posted: 02:21pm 01 Nov 2014
Copy link to clipboard 
Print this post

  Geoffg said  
  TZAdvantage said  Yeah! 64-bit integers!!!
Now that is for me the single most important feature. Together with bitwise operators there are no more limits in usability.

Wait until you get into CFunctions (was called plugins). They have changed out of sight and I have great hopes for them. The beta distribution includes a SerialTx CFunction which adds up to eight transmit serial ports (that is 13 serial ports counting COM1, COM2 and the console).

In the future I hope that people will add extra I2C and SPI channels, encryption algorithms, drivers for special chips and more. They can all be done using CFunctions.

Geoff


Geoff,
Sounds like this will really open up "Open" MMbasic extensible functionality to the USER community .. Well Done !!
 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 437
Posted: 05:01pm 01 Nov 2014
Copy link to clipboard 
Print this post

Let there be light ....

Cfunction provide Ws8211

This Video shows the WS8211 Led stripe powered from my Cfunction on Micromite MK2.

At the moment it can provide up to 85 Leds .

Its not a Lurker .

iam not happy with my code ( to much bytes, only up to 85 leds also) so i fight next days with it to
provide here a lib for the leds.
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 05:41pm 01 Nov 2014
Copy link to clipboard 
Print this post

That is brilliant. It also illustrates what you can do with CFunctions - something that was not possible in BASIC alone.
Geoff Graham - http://geoffg.net
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 06:05pm 01 Nov 2014
Copy link to clipboard 
Print this post

@plasma... brilliant!

I just got a few of those LEDs in this morning and was starting to wonder if MMBASIC or Cfunction couldn't be used for this..

Looking forward to your code...


My Propeller/Micromite mini-computer project.
 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 437
Posted: 12:26am 03 Nov 2014
Copy link to clipboard 
Print this post

Hi,

Iam working on a port to provide much moore
Rgb leds as 85.
At the moment the leds are stored in a string.
Iam thinking about an array but i dont know if
I can dim an array as byte(s).
I know i can use char for this in c but in basic
I need to shift so much bits if i use integers in
Mmbasic

Thx
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1569
Posted: 12:53am 03 Nov 2014
Copy link to clipboard 
Print this post

Hi plasma,

  Quote  Iam thinking about an array but i dont know if
I can dim an array as byte(s).


Dim MyArrayofBytes(500) length 1


does not work in uMite MMBasic?

  Quote  I need to shift so much bits if i use integers in
Mmbasic


I guess there is not a big difference. Because MMbasic (32bit system) needs to do that - or something equivalent - internaly if you are using Bytes. Or i'm completely wrong?

Grüße

Michael




causality ≠ correlation ≠ coincidence
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 01:11am 03 Nov 2014
Copy link to clipboard 
Print this post

You can DIM an array in MMBasic as INTEGER, ie 8 bytes/element. Then in your CFunction treat it as 8 chars per element, ie MMBasic doesn't know what your CFunction is doing with the memory block.

So for example, DIM MEM%(1024) 'Declare Memory block of 8 KBytes

in CFunction, long long main(char *mem){... Code ...}

does that make sense ?

Peter
The only Konstant is Change
 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 437
Posted: 01:11am 03 Nov 2014
Copy link to clipboard 
Print this post

Thx , i take a look
 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 437
Posted: 02:13am 03 Nov 2014
Copy link to clipboard 
Print this post

Right peter , this is what i mean .
I need to calculate the integer in mmbasic for
storing r,gb in and have have 2 bytes free before i can store rgb in the next integer.
I prefere a continued block of mem to become a fast routine without delays from the code.

Maybe the chars from strings are in the memory without spaces or data between ?
I need to test this .

GtxEdited by plasma 2014-11-04
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 06:37am 03 Nov 2014
Copy link to clipboard 
Print this post

So do U mean

R<0..7>G<0..7>B<0..7>Byte<0..7>Byte& lt;0..7>

ie 5 bytes per record/element ?

If so then you could fit the 5 bytes into a 64 bit integer, and just 'waste' the other 3 bytes in the 64 bit integer.

I'm guessing that a UDT like

Type RGB
Byte R
Byte G
Byte B
Byte Spare1
Byte Spare2
End Type

is what you'd like ideally ?


Peter
The only Konstant is Change
 
     Page 4 of 8    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025