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 ZealandPosts: 2350 |
omission in the manual: MM.ONEWIRE is not included in the table on page 32. |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
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: GermanyPosts: 722 |
????? 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 Guru Joined: 31/12/2012 Location: New ZealandPosts: 2350 |
"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 :-) |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3196 |
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 ZealandPosts: 2350 |
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 :-) |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2350 |
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: AustraliaPosts: 1329 |
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: AustraliaPosts: 6102 |
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: ThailandPosts: 2209 |
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: AustraliaPosts: 926 |
At least someone agrees with me |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3196 |
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. Geoff Graham - http://geoffg.net |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
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! |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3196 |
Perhaps it should be an email link: mmlib@geoffg.net Geoff Graham - http://geoffg.net |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Err... yep, dead right Geoff. Must be getting late Greg |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2817 |
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: AustraliaPosts: 3196 |
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: AustraliaPosts: 1329 |
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: AustraliaPosts: 3196 |
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: AustraliaPosts: 1329 |
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 |