![]() |
Forum Index : Microcontroller and PC projects : INPUT Function in CMM2 5.07.02 when using MMCC/MMEdit
Author | Message | ||||
andreas![]() Senior Member ![]() Joined: 07/12/2020 Location: GermanyPosts: 226 |
I wrote a small CMM2 BASIC (version 5.0702) program using MMEdit (Linux) which calculates the line of sight - how far you can see when standing on a tower of hight 'towerhight'. So I had to INPUT the towerhight and then calculate the line of sight. After calculation the program asks again the next value and so forth. I found that I get a 2nd INPUT value after each calculation which has the value <=0. So I had to put in a "busy loop" after each calculation to prevent this. do while inkey$ = "" loop When I use the CMM2 only with keyboard and no terminal connection I don't need the busy loop. So INPUT works correct but not within an MMCC terminal session or the terminal puts in some additional values which are directly feeded into the next INPUT. ' lineofsight.bas ' calculate how far you can see on a tower of hight towerhight ' (2022) Andreas Mueller, Gerolsbach ' const radiusearth = 6371000 ' meters dim towerhight as float = 0.0 cls print "Line of sight" print "=============" do input "Height of tower: ",towerhight if towerhight <= 0.0 then print "Enter a value > 0 please!" else print "Line of sight = ", int(100*sqr((2 * radiusearth * towerhight) + towerhight^2))/100," m" end if do while inkey$ = "" loop loop with busy loop ![]() without busy loop ![]() -andreas |
||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 442 |
It's strange in a different way with the Windows version (no INKEY$ loop) as well: ![]() Edited 2022-09-19 04:47 by toml_12953 |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
In MMCC, set the Tx line-ending to 'LF' rather than CRLF. I find that for the picomites, setting Tx and Rx both to LF is the best option. ![]() You would need to do the same with TeraTerm. Jim VK7JH MMedit |
||||
andreas![]() Senior Member ![]() Joined: 07/12/2020 Location: GermanyPosts: 226 |
Hello Jim, I tried that LF for both Send and Receive but it didn't change the behaviour. Same with CR for both. Then I inserted a PRINT statement which prints the 'towerhight' INPUT value and I found that the second value is "0" ![]() changed program: ' lineofsight.bas ' calculate how far you can see on a tower of hight towerhight ' (2022) Andreas Mueller, Gerolsbach ' const radiusearth = 6371000 ' meters dim towerhight as float = 0.0 cls print "Line of sight" print "=============" do input "Height of tower: "; towerhight if towerhight <= 0.0 then print "Enter a value > 0 please!" else print "Line of sight = ", int(100*sqr((2 * radiusearth * towerhight) + towerhight^2))/100," m" end if print "2nd char"; towerhight 'do while inkey$ = "" 'loop loop -andreas |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Works OK with a non VGA picomite. no second character so the value is the same as the first. I will do some experimenting tomorrow. Jim VK7JH MMedit |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
Perhaps you could input "towerhight" as a string so that you can examine the ascii code of each character. Conversion to a number for the calculation is easy enough. Visit Vegipete's *Mite Library for cool programs. |
||||
andreas![]() Senior Member ![]() Joined: 07/12/2020 Location: GermanyPosts: 226 |
Now it works! I stopped & powered off the MMCC & MMEdit and the CMM2. After switching on the setup shows LF for TX and RX - my latest test. And now it works. So it seems that the MMCC Setup change needs a complete restart. ![]() -andreas |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
Looks like it was "0" because it was a blank line (an extra either CR or LF). When you read a numeric it will be set to 0 if the input is just a line terminator. John |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I am glad it is working for you now. In my tests on Linux, the menu changes to the line ending settings take effect immediately. There should be no need for any restart. Looking at your screenprint, I assume that you loaded the bas file by dragging and dropping onto the desktop shortcut. That is the only reason I can give for the connection to the control port. Not a problem, just interested in how the program gets used. The date of your MMCC is 10th Sept. There is a 15th Sept version posted which fixes Linux printing. You also didn't have the connection to your picomite configured, MMCC thinks it is a CMM2, the old default. That might explain the Timeout. If you setup a connection for the picomite and preferably save it as a device setting, MMCC will use the last setup each time and life will be easier for you. Jim VK7JH MMedit |
||||
andreas![]() Senior Member ![]() Joined: 07/12/2020 Location: GermanyPosts: 226 |
Hi Jim, No, I'm clicking the "Load file and run it" button within MMEdit Oh, I will download the latest version and test it! I'm using MMEdit with my CMM2 (!) - the USB power connector is connected to my main PC running Linux (Mint Version 21 "Vanessa") So the Colour Maximite 2 gets its power and control by the USB cable. I have setup CMM2 with ttyACM0 115200 within MMCC as MySite ![]() -andreas |
||||
andreas![]() Senior Member ![]() Joined: 07/12/2020 Location: GermanyPosts: 226 |
Hello John - yes that is a good explanation! -andreas |
||||
andreas![]() Senior Member ![]() Joined: 07/12/2020 Location: GermanyPosts: 226 |
A picture says more than 1000 words ;-) ![]() -andreas |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Sorry I missed the fact that you are running your CMM2 - my mistake. I run my CMM2 at 460800 baud reliably. It makes file transfers much easier to take. Last time I tried, the CH340 USB-TTL didn't work with my VM so I can't test it from Linux. There has been an update to the VM so I must try again. If I could access the CMM2 from Linux, I would use Linux more often for testing. Jim VK7JH MMedit |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |