Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:36 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 : Introducing the Pi-cromite: first steps

     Page 13 of 16    
Author Message
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 03:13am 20 Jun 2017
Copy link to clipboard 
Print this post

OK, yes i missed it ;-(((


::::::::::


This release also includes support for two uarts COM1 and COM2. Syntax is as per the Micromite and print #, input #, line input #, and input$ should all work as normal

Pins are COM1-RX 10, COM1-TX 8, COM2-RX 11, COM2-TX 7

The parameters supported are baudrate (1-115200), buffer size (defaults to 2048), interrupt routine and number of characters before the interrupt. All transmission is 8N1.
DE, 9BIT, INV, OC, and S2 are not supported, nor is IEEE-485

Note the input is buffered as per the Micromite but the output is blocking.
The RX pin is not pulled up in software so this may be required in H/W if the pins may be left disconnected with the serial port open. Remember the Pis are 3.3V ONLY!!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10195
Posted: 05:48am 20 Jun 2017
Copy link to clipboard 
Print this post

  Quote  "OPEN "/ dev / ttyUSB0" FOR RANDOM AS # 5 'open the serial port"

Didn't know that Picromite can do things like this.
How could i know if not documented, or did i miss it somewhere ??


This is different to the serial port commands listed above. Because Linux treats all peripherals as though they are files you can use the file I/O commands to talk to them as above.

gumath has opened the USB port as a file with random access giving both input and output capability
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 06:17am 20 Jun 2017
Copy link to clipboard 
Print this post

/dev/ttyUSB0

Shows me that he attached a USB to rs232 adapter to the USB port.

Am I wrong?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10195
Posted: 07:45am 20 Jun 2017
Copy link to clipboard 
Print this post

  Quote  /dev/ttyUSB0

Shows me that he attached a USB to rs232 adapter to the USB port.

Am I wrong?


You are correct. The point I was making is that he is opening it as a random access file not as a serial port

OPEN "/ dev / ttyUSB0" FOR RANDOM AS # 5


vs

OPEN "COM1:9600" AS # 5


 
gumath
Newbie

Joined: 25/04/2017
Location: Austria
Posts: 10
Posted: 07:52am 20 Jun 2017
Copy link to clipboard 
Print this post

@ atmega8

"/ Dev / ttyUSB0", when using USB serial converter.

On page 6 described in this tread, by TassyJim.

Thanks Jim !!!

I have already read these 20 pages 3x, and find
Always something new.

Vy 73 de Guenter, OE7GMT
 
hitsware
Guru

Joined: 23/11/2012
Location: United States
Posts: 535
Posted: 11:06am 20 Jun 2017
Copy link to clipboard 
Print this post

No control of baudrate with " / dev / ttyusbo " ?
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6266
Posted: 12:24pm 20 Jun 2017
Copy link to clipboard 
Print this post

  hitsware said   No control of baudrate with " / dev / ttyusbo " ?

NO, but there is a system command which should be able to set the baud rate.
It will need a Linux user to provide the preferred command to use. I find Linux has many ways to do tasks and I am at a loss when it comes to the "correct" way.

Jim

VK7JH
MMedit
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 12:42pm 20 Jun 2017
Copy link to clipboard 
Print this post

  hitsware said   No control of baudrate with " / dev / ttyusbo " ?



Setting serial port parameters under Linux are done with stty commands.

For example:

stty -F /dev/ttyUSB0 115200
sets the baudrate to 115200.

Try man stty for many other settings,

or online man pages :
Stty


 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 02:54pm 20 Jun 2017
Copy link to clipboard 
Print this post

  hitsware said   No control of baudrate with " / dev / ttyusbo " ?

USB does not have a baud rate.
Only a USB to serial converter uses that to set the UART side of the converter.
A builtin USB device does not have a UART.
Microblocks. Build with logic.
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 09:17pm 20 Jun 2017
Copy link to clipboard 
Print this post

  MicroBlocks said  
  hitsware said   No control of baudrate with " / dev / ttyusbo " ?

USB does not have a baud rate.
Only a USB to serial converter uses that to set the UART side of the converter.
A builtin USB device does not have a UART.



As you can see with ls -l /dev/ttyUSB0:
crw-rw---- 1 root dialout 188, 0 Jun 21 09:06 /dev/ttyUSB0
it is a serial character Device.

Also you CAN set and you NEED to set a baudrate (and other Framings) if the Application (Putty/Minicom/PIcomite..) does not set it!
set with "stty -F /dev/ttyUSB0"
and read with "stty -F /dev/ttyUSB0 speed",
here 4800.

Play with putty, set speed, and read it from another shell with stty -F /dev/ttyUSB0.

This way you can set a baudrate when using Picromite´serial communication.

DS


Edited by atmega8 2017-06-22
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 10:08pm 20 Jun 2017
Copy link to clipboard 
Print this post

  TassyJim said   More playing, this time with a USB-TTL converter.
  Quote   ' serial test program
OPEN "/dev/ttyUSB0" FOR RANDOM AS #5 ' open the serial port
PRINT #5, "HELLO!!! Is anyone out there?"
DO ' one way to receive serial data which might not be there!
k$ = INPUT$(1,#5)
IF k$="" THEN
nodata=nodata+
1
ELSE
result$=result$+k$
PRINT result$
nodata=
0
ENDIF
PAUSE 20
LOOP UNTIL k$=CHR$(10)OR nodata=50 ' 50*20ms = 1 second timeout
CLOSE #5


There doesn't seem to be a way to change the baud rate yet. My FTDI converter defaulted to 9600 baud.

It seems to need the "FOR RANDOM" bit in there so we think its a file.

A Linux observation - The text is sent with a <LF> only so if you are waiting for the <CR>, you will be disappointed.

So far I have tested with a loopback plug on the serial adapter but there is no reason a micromite couldn't be sitting there.

This version on MMBasic doesn't save your code between sessions so remember to do a SAVE before exiting!

Jim


So use stty -F /dev/ttyUSBx 38400 ...or what you need on the bash
 
gumath
Newbie

Joined: 25/04/2017
Location: Austria
Posts: 10
Posted: 10:40pm 20 Jun 2017
Copy link to clipboard 
Print this post

@ atmega8

Thanks for the tip !!!

I will be testing extensively tonight.

Thanks again,
Vy 73 de Guenter, OE7GMT
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10195
Posted: 12:01am 21 Jun 2017
Copy link to clipboard 
Print this post

Please find attached version 5.4.a05

2017-06-21_094453_mmbasic.zip

Please delete the OPTIONS file before use: "rm .options"

I need help from Pi 3 owners to test a specific change in this release.

There is a known issue with pigpio that the timing of waveforms created with the DMA wave output functions are incorrect on some, but not all, Pi 3s. Other Pis do not seem to be affected.

This functionality is used for serial comms output and the new "BITSTREAM" command. Note other time based MMBasic functions are correct - this issue is specific to the pigpio wave functionality.

The timings are wrong on my Pi 3 and in release 5.4.a04 and below I used a frig factor of 1.128 to correct the timings. However, gumath has reported that this didn't work on his Pi 3.

To rectify this I have introduced a new option WAVETIME which defaults to 1.0

Syntax is: OPTION WAVETIME number

In my case I use "OPTION WAVETIME 1.128" to get correct serial output. The value is permanently stored in the .options file. If the value isn't 1.0 then the value in use will be reported when you use OPTION LIST

So, if you have a Pi 3 please could you test serial output for me. First try the release as delivered (WAVETIME=1.0). If that doesn't work (i.e. you get garbled output) try 1.128.

If that also doesn't work and you have access to an oscilloscope or logic analyser please try the following:

open "COM1:1000" as #1
do
print #1,"U";
loop


This generates a stream of characters where the bit length should be exactly 1 millisecond and character "U" toggles the bits.

Please measure the actual length of the bit and report back. You can then use the measured bit length to correct serial output WAVETIME = measured_bit_length/required_bit_length.

Please also let me know the exact version of the Pi 3 you are testing on - mine is the Pi 3 Model B V1.2 and MM.DEVICE$ reports A02082

Thanks for any and all help on this one.
Edited by matherp 2017-06-22
 
RonnS
Senior Member

Joined: 16/07/2015
Location: Germany
Posts: 121
Posted: 03:49am 21 Jun 2017
Copy link to clipboard 
Print this post

Hello Peter,
first many thanks for your work.

I've done first experience with the BITSTREAM Command. I have connect a Pi with an 433 mhz Transmitter and run my Remote Control Code .
It worked only a part of the code immediately, this part sent a 24 bit stream to a Led controller, over the 433 mhz transmitter, so I can say it works in principle .
- the other part should send a 32 bit stream - i have to work on it
My other impression was that the Pi then swings by itself and does not stop again
I could not measure any results with my logic analizer - I had to terminate mmbasic to stop everything.Tested with V5.4.04 and i have the same Raspi version as you

regards RonEdited by RonnS 2017-06-22
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10195
Posted: 05:06am 21 Jun 2017
Copy link to clipboard 
Print this post

Ron

Have you upgraded pigpio to V64? see 2nd post on page 19

If you still have problems please post sample code that causes the problem

 
RonnS
Senior Member

Joined: 16/07/2015
Location: Germany
Posts: 121
Posted: 05:32am 21 Jun 2017
Copy link to clipboard 
Print this post

  matherp said   Ron

Have you upgraded pigpio to V64? see 2nd post on page 19

If you still have problems please post sample code that causes the problem



hi Peter ,

pigpiod -v. gives me a 64 back...( now ;) )

I will keep trying it again :) and will report then

it could be that the problem caused in the changed "end of transmission"

thank youEdited by RonnS 2017-06-22
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 11:11am 21 Jun 2017
Copy link to clipboard 
Print this post

Peter,

while testing the new version, i could see, that just starting mmbasic, it consumes more than 90% CPU, no programm runnig !!!!

Also deleted .options.


26629 root 20 0 22492 7416 2604 R 92,8 1,7 2:16.05 mmbasic
3 root 20 0 0 0 0 S 3,8 0,0 0:13.94 ksoftirqd/0
23885 pi 20 0 5580 2520 2136 R 1,7 0,6 0:02.77 top


PS.: Why is my stored Programm deleted when i exit
mmbasic and start it again??

THX
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10195
Posted: 11:29am 21 Jun 2017
Copy link to clipboard 
Print this post

  Quote  PS.: Why is my stored Programm deleted when i exit
mmbasic and start it again??


Programs are stored in RAM so are deleted when you exit same as mmbasic for DOS or maximite

  Quote  t consumes more than 90% CPU, no programm runnig !!!!


All versions of mmbasic sits in a tight loop while waiting for input. On the Pi it runs as priority 0 so Linux will timeslice it if required
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 12:10pm 21 Jun 2017
Copy link to clipboard 
Print this post

  matherp said  
  Quote  PS.: Why is my stored Programm deleted when i exit
mmbasic and start it again??


Programs are stored in RAM so are deleted when you exit same as mmbasic for DOS or maximite



So, when I use the internal editor and store the Programm it is lost when I exit mmbasic?

  Quote  t consumes more than 90% CPU, no programm runnig !!!!


Ok.

All versions of mmbasic sits in a tight loop while waiting for input. On the Pi it runs as priority 0 so Linux will timeslice it if required
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 12:13pm 21 Jun 2017
Copy link to clipboard 
Print this post

Settings in .options are not stored in ASCII format, correct?
 
     Page 13 of 16    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025