Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:52 29 Nov 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 : Micromite Beta 10

     Page 2 of 4    
Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 01:07am 10 Mar 2014
Copy link to clipboard 
Print this post

omission in the manual: MM.ONEWIRE is not included in the table on page 32.
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:04am 10 Mar 2014
Copy link to clipboard 
Print this post

Hi Geoff,

I have a request and a possible bug.

Is it possible to mod the new STR$ function to allow padding with either spaces or zeroes. I'm using an LCD display (4x20) for a mins/secs timer with the following commands below. (The 01:04 example is previously set via a keypad but might be e.g. 15:30).


lcd 1,1, " Time set = 01:04 "
settick 1000,countdown
lcd 2,13, str$(dispmins,2) +":"+ str$(dispsecs,2)

countdown:
totsecsrem = totsecsrem - 1
print totsecsrem
if totsecsrem = 0 then lamps_off
remminsec = totsecsrem/60
dispmins = fix(remminsec)
dispsecs = cint((remminsec - dispmins)*60)
print remminsec, dispmins, dispsecs
lcd 2,13, str$(dispmins,2) +":"+ str$(dispsecs,2)
ireturn


When the Countdown drops below " 1: 1" it shifts left by one character and displays 3 digits instead of 2 for the seconds (the 3rd is a "1" left over from the countdown at 1 second.)

" Time set = 01:04"
"Countdown = 1: 3"
"Countdown = 1: 2"
"Countdown = 1: 1"
"Countdown = 1: 1"
"Countdown = :591"

As you can see it looks a bit odd without the leading zeroes and the extra " 1: 1" instead of " 1: 0" seems to be a bug.
The corresponding output on the console from the "PRINT" command is:

62
1.03333 1 2
61
1.01667 1 1
60
1 1 0
59
0.983333 0 59
58 etc


Greg

 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 722
Posted: 04:42am 10 Mar 2014
Copy link to clipboard 
Print this post

?????

Each configured interrupt services its own service routine, so The relation IS given!?

Trigonometric Functions will consume lots of space.
So all peoples lose Space, also trig not used...


  robert.rozee said   against my better judgement, can i request a couple of features :-)

1. the means for an interrupt service routine to tell what action called it. in some applications, one isr may be able to service interrupts generated by (in particular) several different pins. as far as i can see, there is currently no way for the isr to tell what the source of the interrupt was. a simple solution would be to introduce a variable called MM.INTPIN that is set to the number of the pin that generates an interrupt, with perhaps the polarity of the signal on the pin indicated in the sign of MM.INTPIN (+ve = high, -ve = low, 0 = non-pin generated interrupt).

2. please, please, please add the following functions:
ASIN
ACOS
ATAN (as an alias for ATN).
for anyone wanting to do any trig functions this saves a load of messing around with trig identities.

rob :-)
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 01:07pm 10 Mar 2014
Copy link to clipboard 
Print this post

  atmega8 said  Each configured interrupt services its own service routine, so The relation IS given!?

Trigonometric Functions will consume lots of space.
So all peoples lose Space, also trig not used...

"also trig not used...": in various applications trig functions very much are used. try building a self-balancing robot, or any number of pieces of surveying equipment, without using trigonometry. the code space required to expand beyond ATN() is very small as the remaining two (ASIN and ACOS) are just identities derived from existing functions.

as for introducing an MM.INTPIN variable, this would (in some applications) allow a saving in user code by allowing a single isr to replace multiple ones. i'm suspecting that internally MMbasic well knows the source pin anyway, so it is just a matter of storing the value in a user-accessible place. indeed, at the moment it may even already be accessible via a suitable PEEK.

rob :-)Edited by robert.rozee 2014-03-11
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3196
Posted: 01:40pm 10 Mar 2014
Copy link to clipboard 
Print this post

  robert.rozee said   against my better judgement, can i request a couple of features :-)

1. the means for an interrupt service routine to tell what action called it. in some applications, one isr may be able to service interrupts generated by (in particular) several different pins. as far as i can see, there is currently no way for the isr to tell what the source of the interrupt was. a simple solution would be to introduce a variable called MM.INTPIN that is set to the number of the pin that generates an interrupt, with perhaps the polarity of the signal on the pin indicated in the sign of MM.INTPIN (+ve = high, -ve = low, 0 = non-pin generated interrupt).

2. please, please, please add the following functions:
ASIN
ACOS
ATAN (as an alias for ATN)


I'm sorry Rob if I sound difficult but I cannot see why these are necessary.

If you want to know what caused an interrupt you would just use different interrupt labels. In your suggestion a single interrupt subroutine would need a sequence of IF/THEN statements to determine what caused the interrupt. Why not use different labels in the first place? It would be cleaner and much easier to debug.

And I am afraid to say that a similar thought process applies to ASIN, ACOS, etc. They can be easily created by using straight forward formulae available on the internet. You could even pack them into a function. For example, here is your ATAN alias:
Function ATAN(x)
ATAN = ATN(x)
End Function


A computer language needs to be compact and succinct. If you pack too many unnecessary features into it it becomes unwieldy and hard to understand. MMBasic is not a perfect language because a number of unnecessary "features" have inadvertently found their way into the language but I try very hard to avoid adding any more. For that reason I thought long and hard before adding the LCD command and it was only its value to a beginner programmer that won the day.

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

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 02:35pm 10 Mar 2014
Copy link to clipboard 
Print this post

the addition of MM.INTPIN would (i'm assuming) consume just a few more bytes of code in the interpreter, but be useful in cases where a sequence of pins are assigned to a similar task.

for instance (a contrived example), when a keyboard is hooked up to a number of pins. if one has a 6x6 keyboard with pins 2 to 6 scanned and pins 21 to 26 used as inputs, an isr and other associated code might look like:

'
' set up pins 2-6, 21-26 as appropriate, with 21-26
' all generating an interrupt pointing to columnISR
'
DO
keycode = 0
FOR rowpin = 2 to 6
PULSE row, 1
PAUSE 2
NEXT rowpin
'
' keycode now contains either 0 or a 2-digit key number,
' the first (10's) digit being the column number, the second
' (1's) digit being the row number
'
if keycode <> 0 THEN PRINT keycode
LOOP


columnISR:
keycode = (MM.INTPIN-20) * 10) + (rowpin - 1)
IRETURN

the above uses the availability of the interrupting pin to save on 5 labels and either the duplication of the multiplications, etc, or a bunch of IF statements. not to mention, the code is a whole lot cleaner to read.


the inclusion of ASIN, ACOS and ATAN brings MMbasic in line with many other basics that include a complete set of trig functions. you are right that the user who knows how can write their own ASIN() and ACOS() functions, but for many beginners this might be pushing their maths abilities a bit - especially if they are translating code from elsewhere. some people (ahem) don't even believe that trig functions are necessary at all.

it would be a 'nice' addition to the language that would make it more accessible to beginners who's application involved a little non-cartesian real world geometry. as for ATN, that is just a hangover from trying to fit all function names into 3 characters!

remember, any programming language needs to be a balance between succinctness and accessibility. while not essential, things like the LCD commands aid in accessibility to the beginner and adds utility that make the language more appealing to those we want to encourage into computing.


rob :-)
Edited by robert.rozee 2014-03-12
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 05:37pm 10 Mar 2014
Copy link to clipboard 
Print this post

another small error in the manual:
page 25 contains the line, "PRINT TIME$, PIN(1)". the number should be 2, and not 1 (pin 1 being the reset pin).
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 06:55pm 10 Mar 2014
Copy link to clipboard 
Print this post

A minor error in Manual also. Page 50, the new STR$ examples - the bottom two lines should be STR$(53,..., not STR$(55,...
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6102
Posted: 07:17pm 10 Mar 2014
Copy link to clipboard 
Print this post

  robert.rozee said  
the inclusion of ASIN, ACOS and ATAN brings MMbasic in line with many other basics that include a complete set of trig functions. you are right that the user who knows how can write their own ASIN() and ACOS() functions, but for many beginners this might be pushing their maths abilities a bit - especially if they are translating code from elsewhere. some people (ahem) don't even believe that trig functions are necessary at all.
rob :-)


ASIN and ACOS are easy to do if you have ATN and SQR which MMbasic does have.

They are both one line functions.
I would like to see a collection of this sort of functions included in the Maximite manuals (but who reads manuals?).

main:
input "Angle in degrees? ",n
a= rad(n)
print str$(n)+" degrees = "+str$(a)+" radians"
print "SIN = "+str$(sin(a))
print "ASIN("+str$(sin(a))+") = "+str$(asin(sin(a)))
print " "
print "COS = "+str$(cos(a))
print "ACOS("+str$(COS(a))+") = "+str$(acos(cos(a)))
print " "
goto main

function ASIN(x)
ASIN=2*ATN(x/(1+SQR(1-x*x)))
END FUNCTION

function ACOS(x)
ACOS=1.5708- ASIN(x)
end function


This code should run OK on Maximite, MicroMite and DOS.
The next problem with be the slight differences in some of the values, especially around 90 180, 270 degrees. All well within the accuracy of 32 bit floating point but sure to concern some.

Jim

VK7JH
MMedit   MMBasic Help
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 09:56pm 10 Mar 2014
Copy link to clipboard 
Print this post

Lookup tables also work in some cases.
Helps make it fast too.
It can be enough when you need it to draw something on a screen. The screen resolution is often to coarse to see a difference between a calculated value or a rounded to a single degree lookup value.

Microblocks. Build with logic.
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 11:14pm 10 Mar 2014
Copy link to clipboard 
Print this post

  paceman said   A minor error in Manual also. Page 50, the new STR$ examples - the bottom two lines should be STR$(53,..., not STR$(55,...

At least someone agrees with me
  Quote  Posted: 02 March 2014 at 8:05pm | IP Logged Quote Graeme Meager


Thank you again Geoff, cannot wait to start playing with the new commands.

Could this be a small typo on page 50? Or am I interpreting it wrong ?




STR$(55, 6) will return " 53"
STR$(55, 6, 2) will return " 53.00"




All the best
Graeme
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3196
Posted: 11:55pm 10 Mar 2014
Copy link to clipboard 
Print this post

Thanks paceman, I will fix it.

Graeme, thanks for your post and my apologies for not picking up on it - but you could have been more specific and less cryptic. Remember that I originally wrote it, then re read it many times and did not spot the error. When you posted the exact same text I just re read it again and still did not spot the error or what you were hinting at. Finally, this time, with the help of paceman I have spotted it.Edited by Geoffg 2014-03-12
Geoff Graham - http://geoffg.net
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 12:54am 11 Mar 2014
Copy link to clipboard 
Print this post

  TassyJim said  
ASIN and ACOS are easy to do if you have ATN and SQR which MMbasic does have.

They are both one line functions.
I would like to see a collection of this sort of functions included in the Maximite manuals (but who reads manuals?).

Jim,
That'd be good but requires a lot more messing around from Geoff - and I reckon he's ten times as busy as a lot of us already! (maybe 2x for you ) I think the library is the place for it and it probably needs a MicroMite section now along with the Maximite entries. BTW I haven't seen much of Hugh lately - anyone know what he's up to?

For those who mightn't know, Hugh Buckle manages the MMBasic library, at Attn Hugh and the current version (March 6th 2014) can be downloaded from Geoff's website at MMBasic library

Greg

Edit: Hmmm... got a 404 Error on "mmlib@geoffg.net". Not sure what's happening here!Edited by paceman 2014-03-12
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3196
Posted: 01:29am 11 Mar 2014
Copy link to clipboard 
Print this post

Perhaps it should be an email link: mmlib@geoffg.net
Geoff Graham - http://geoffg.net
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:45am 11 Mar 2014
Copy link to clipboard 
Print this post

Err... yep, dead right Geoff. Must be getting late

Greg
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2817
Posted: 10:23am 11 Mar 2014
Copy link to clipboard 
Print this post


Confirmed consistent strange behaviour on something that is NOT a show stopper. Occurs on 44-pin PICs (not tested on 28pin PIC).

When using the built-in editor on a MicroMite, if in the FIRST line you type a '?' at the start of the line (i.e. '? "Hello") then when you press return, the cursor jumps down to the next line as expected but ALWAYS puts in a space character before the cursor.

Using the word 'Print' on the first line does not do this and the cursor is in the correct place. Other commands on the first line also work as expected. And using a '?' on any other line works ok when return pressed.

So it just appears to be a '?' on the first line in the first column that when return is pressed, causes the cursor to jump to the second line but second column.

Can other people confirm this happens to them too? It should only take a couple of seconds to check this. Does it happen on 28pin PICs too?

Geoff - is this a little tiny bug or is there another explanation to this behaviour?

Awaiting any replies . . .


For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3196
Posted: 11:05am 11 Mar 2014
Copy link to clipboard 
Print this post

This is a bug and it will also be in the 28-pin version. In fact it is also in all versions of MMBasic including the Colour Maximite.

I have never been able to consistently make this bug show up so your find is valuable. Also, because it was so trivial I did not have a large incentive to chase it. Now that I can make it appear on demand it should be easy to fix. Thanks.

Geoff
Geoff Graham - http://geoffg.net
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:36pm 11 Mar 2014
Copy link to clipboard 
Print this post

Geoff, did you see my post at 11:04 on the 10th. Just wondering what you think and if I should be trying to work around it.

Greg
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3196
Posted: 04:44pm 11 Mar 2014
Copy link to clipboard 
Print this post

I did Greg but I just don't have the time to wire up an LCD and reverse engineer your program. Can you distil it down to a few lines that will actually run (your code falls over with errors)?

On leading zeros. I hope to put something into the next version that will help with this.

Geoff
Geoff Graham - http://geoffg.net
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 04:52pm 11 Mar 2014
Copy link to clipboard 
Print this post

Sorry, OK will do. I didn't realise that code error-ed out; I extracted it from a bigger section.

A future for leading zeroes - excellent, thanks!

Greg
 
     Page 2 of 4    
Print this page
© JAQ Software 2024