Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:03 01 Aug 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 : INPUT Function in CMM2 5.07.02 when using MMCC/MMEdit

Author Message
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 226
Posted: 03:10pm 18 Sep 2022
Copy link to clipboard 
Print this post

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
 print
 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 States
Posts: 442
Posted: 06:46pm 18 Sep 2022
Copy link to clipboard 
Print this post

  andreas said  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.


-andreas


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: Australia
Posts: 6283
Posted: 08:50pm 18 Sep 2022
Copy link to clipboard 
Print this post

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: Germany
Posts: 226
Posted: 11:31am 19 Sep 2022
Copy link to clipboard 
Print this post

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
 print
 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: Australia
Posts: 6283
Posted: 11:57am 19 Sep 2022
Copy link to clipboard 
Print this post

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: Canada
Posts: 1132
Posted: 03:08pm 19 Sep 2022
Copy link to clipboard 
Print this post

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: Germany
Posts: 226
Posted: 03:31pm 19 Sep 2022
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 4044
Posted: 06:53pm 19 Sep 2022
Copy link to clipboard 
Print this post

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: Australia
Posts: 6283
Posted: 09:24pm 19 Sep 2022
Copy link to clipboard 
Print this post

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: Germany
Posts: 226
Posted: 02:19pm 20 Sep 2022
Copy link to clipboard 
Print this post

Hi Jim,

  TassyJim said  
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.


No, I'm clicking the "Load file and run it" button within MMEdit

  TassyJim said  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.


Oh, I will download the latest version and test it!

  TassyJim said  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


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: Germany
Posts: 226
Posted: 02:20pm 20 Sep 2022
Copy link to clipboard 
Print this post

  JohnS said  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


Hello John - yes that is a good explanation!

-andreas
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 226
Posted: 02:37pm 20 Sep 2022
Copy link to clipboard 
Print this post

A picture says more than 1000 words ;-)

-andreas
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:44pm 20 Sep 2022
Copy link to clipboard 
Print this post

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
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025