Articles Hierarchy

Articles Home » RPI » revive PMS3

revive PMS3

newest update

with a new RPI2B board and the system optional WHEEZY or JESSIE ( as 2 SD cards ) i want work again.

i had a PMS3 project: Poor Man Scope with 3 Channel,
it is working on a variety of hardware,
-- sampling: arduino UNO, DUE or MAX32
-- visualization: PC or RPI ( HDMI or headless via PC )
-- software: processing or python ( for PC and RPI )
my last BLOG about scope was here and here and here and here and here and here and here and also some old versions at download area ( or just as link to zip file from inside the blog).

here in my BLOG i have that so called CATEGORIES: "arduino", raspberry pi", and even "processing", and also in my entry page "news" WORK BLOG i have 2 sections: "arduino" and " raspberry pi". all that structure not makes sense any more. poorly this old CMS php-fusion 7.2.7 does not support tags. UPS there is a addon i have to test

and so my documentation and software / downloads about that also very confusing, because historically grown.
but that it is what it is about, with the new faster RPI2B i could test processing again for visualization, even on the sampler hardware side no news.

as i tested MAX32 , but it is a 3v3 board so needs a voltage divider at the Ains to be used for the 5V world or even bigger voltages ( also DUE board).
and it even needs a different USB cable,
also it needs a different ( modified arduino 0023 ) IDE, but now also for raspberry pi available!
on PC from here download/update with "" 220MB
upload project: PMS33 (MAXcopy) ok
in line chart mode test: one channel 513kHz, 3 channel 65kHz

Arduino Boards
here i have the IDE 1.6.5 nightly called "1.6.6 hourly build" from here
upload project PMS33 (UNOcopy see //#define usePROCESSING ) ok as "3 channel line chart" on UNO
no ram for 3 channel 360 processing scope, but 38 samples for one page line chart good.

you see the 38 lines plus one info line in IDE monitor,
with [+] or [-] can adjust sample rate from 1 channel 35kHz , 3 channel 14kHz .. 24Hz,
and in NO BATCH mode ( line by line analog read and print mode ) down to 30sec sample rate.
above use 1.3kHz ( 38 samples in 28msec batch ) and a open wire at Ain0 touch by hand as antenna for stray 50Hz. you see 26 samples is one sinus, 1315HZ/26=50Hz

when i made that PMS3 code i learned that UNO is to small for the 360samples / 3 channel int array
so i use the "no use processing" thinking means only show 38samples / 3 channel int array for line chart.
implicit i wanted to say: if you use a UNO and the processing "scope" visualization, better use PMS2 only.
now with this release ( PMS34 ) i think i could make a automatic compiler switch to solve this.

first i had to dismantle my DUE process control system, then
download IDE 1.6.5 r2 (146MB) for test with DUE ( 1.6.5 nightly has no DUE )
again not see DUE board, use BOARD MANAGER, load arduino SAM board ( slow downloading of 85MB more )
upload PMS33due
first using line chart ( //#define usePROCESSING ) again and see 76kHz 3 channel and
655kHz 1 channel ( but then can not change sample rate / screen freeze at next operation )
have to check on update reg. "STIMMER", anyhow close/open terminal resets DUE
but that would make DUE the fastest board.

all 3 boards and software IDEs parallel.
the 3 code projects are ( should be ) same besides some compiler switches "//"
and the MPIDE *.pde naming requirement

as i already make small changes make it a PMS34 ( 3 channel, revision 4 )

update onWin7 PC: from here i download/update "" 115 MB
load PMS33 / make PMS34 / run. As MAX32 (COM10) and Arduino Due (COM12) running
the "Serial.list()[1]" connected me to MAX32. Now i want to show you a nice picture so get one more board ( Arduino MICRO PRO ) to make me a signal

here i move from PC to RPI2B

but first install on RPI2B WHEEZY the new processing:
i last time use processing-2.1-linux32 and did not get the serial interface running, now i follow here to use newer version, still the actual would be this
try the newer version first:
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install oracle-java7-jdk 70MB
sudo update-alternatives --config java 0 auto jdk8, 1 manual jdk7, 2 manual jdk 8: i select 1???
wget 98MB
tar xvzf processing-2.2.1-linux32.tgz
rm -rf ~/processing-2.2.1/java
ln -s /usr/lib/jvm/jdk-7-oracle-armhf ~/processing-2.2.1/java
wget 276kB
mv jSSC-2.6.0-Release/jssc.jar ~/processing-2.2.1/modes/java/libraries/serial/library/
(remove the jSSC folder: rm -r jSSC-2.6.0-Release )
runtest, no serial ...

now as long processing 2xx use JDK7 and not JDK8 hardfloat the improvement could be only by the RPI2B speed. with processing 3 all will be better?? update here
try to run the project but can not find its libraries??
my processing preferences sketchbook points to /home/pi/sketchbook/processing/
and there in /libraries/ i put: Arduino.jar, arduinoscope.jar, controlP5.jar
prior it worked ( and still under windows with same 2.2.1 version ) with that libraries inside a /code/ subdir with the project.
hmm, a version problem? see here
still error cc.arduino not found, that is about the linux name problem:
rename the "new" /home/pi/yoursketchbook/libraries/arduino/library/Arduino.jar to arduino.jar, now load ok

for arduino have the IDE 1.6.5 for raspberry MAX32 MPIDE need
wget 242MB
tar xvzf /home/pi/mpide-0023-raspberrypi-20140821.tgz
yes better would be under /usr/share/ where also arduino IDE is.

here even a 1.5.0 version available??
anyhow now follow this:
sudo apt-get install gcc-avr ( should be there for arduino already exists_OK )
sudo apt-get install librxtx-java i remember, that's the bad one exists_OK
Add the following lines to your .profile: ... // can also be part of start like with arduino
see sudo cat /usr/bin/arduino
Disable console on serial port on RPi? // should not be needed
hard link named /dev/ttyS0 to /dev/ttyAMA0 and start by ./mpide // could be done like arduino start
here is what i try:
cd /usr/share/applications/
sudo cp arduino.desktop mpide.desktop
sudo nano mpide.desktop
name MPIDE0023 , exec mpide0023
cd /usr/bin/
sudo cp arduino mpide0023
sudo nano mpide0023
that code you will find in download pack later
so, MPIDE start via desktop menu,
but intro picture missing, version info missing, port grey,
when i start ./mpide manually add see a warning:
RXTX Version mismatch jar: 2.1.-7, lib: 2.2pre2
just to be sure i do the 3 additional hevangel things
3. sudo ln -s /dev/ttyUSB0 /dev/ttyACM0
4. sudo usermod -a -G dialout pi
5. sudo usermod -a -G tty pi
anyhow copy in my PMS34 sketch from MPIDE of PC and open in RPI MPIDE
connect MAX32
port see /dev/ttyUSB0 select
verify, upload, monitor OK

run PMS3 on RPI2B / wheezy / processing 2.2.1 / by MAX32 PMS3 scope and a "Arduino micro pro" testsignal

after change port in processing sketch list[2] it runs. but it seems to be an old code, need the update with the zoom buttons / copy PMS43 from PC OK
and for channel 2 and 3 have signal problem, even i have no idea what could be different now from the last PC setup? USB HUB? ( a additional GND wire MAX32 Arduino MICRO PRO not helped )
but download SAME CODE via MPIDE from PC to MAX32 back to RPI

now after copy new MPIDE code from PC to RPI again and copy it to arduino sketchbook
at compiler ( verify) start the .pde are renamed to .ino ( not by IDE 1.0.1 ??)
running Arduino 1.6.5 on RPI i need again first use board manager to be able to use DUE
but compile give error

test the UNO with the new compiler switch ( back to 2 channel ) worked in chart line and processing

but could not close scope window, so try again that prepared switch
#define useRPI what slows serial com down for RPI. ( same baud rate but delays in sending // that needs tuning) use
//#define useRPI
anyhow UNO 2 channel trick works now

detailed system layout:

i have to get the PYTHON tools ( as processing replacement ) also running again, see here
and its autostart
first on PC

starting the from python IDE 2.7.6
and adjust COM10, i see warnings about "TOO SHORT LINE" ( seems to be between info line and first data set?? need check arduino code )
and a batch CSV write of 10 files ( 1 info line , 360 data lines) to C/temp ( about every 1.4sec )
starting it with double click execute it directly in python.exe and start the scope by python IDE,

now i want to make PC and RPI version same by detecting OS.
here after copy to RPI the stream run by python2 IDE for diagnostic

but you can also just start it from terminal by
python /home/pi/sketchbook/python/
after do the auto start thing on the service ( see file and info )

After you have the matplot lib installed
sudo apt-get install python-matplotlib
you can start the scope from terminal
python /home/pi/sketchbook/python/
or by the new desktop icon.

what i see after first start was that i get every 1.4sec a new dataset from arduino (due)
to a csv file in RAM_DISK, but the scope shows [conti] mode, only every 2nd,
? because of this? timer = fig.canvas.new_timer(interval=2000) # 2 sec
so, with the new and faster RPI2 have to check on all timing on arduino and RPI side.
ok, displayupdate 1sec (1000) ok, read every file now.

somewhere on the way to here i lost my arduino micro pro
when i connect it to any computer i not see a USB device ( as it was a leonardo i should see even 2 )
if i burn it by breadboard wiring or if it is possible that i killed it by a broken upload ??

for operation pls find 2 desktop files:
one for stop/start/restart/ or check the service
one for starting the scope.
code or load it from RPI with

for the service i work on the operation from desktop,
because if you make it autostart / at boot /
but later need to change the arduino ( arduino IDE .. ) the port is blocked by the service,
you need to stop it first, that operation is possible by click on a icon.
for a little framework only about that autostart and operation pls see here

i work from remote ( headless / remote desktop program (xrdp installed))
and i see a problem that the RPI2 desktop sometimes can not be operated,
spec. the scope window can not be closed. ( but screen not frozen / see data update... )
but on headerline "program" right click "close window" works
but when i close and reopen the RDP window, the operation (closing the windows ) is possible again.
could be a problem with the PC RDP.

long time has gone by that i used this, but now i moved from
"desktop application" to "web service", means still a python service has to catch the arduino (batch) stream to files at RPI RAM DISK, but the whole visualization and operation is now via a web page, what is part of a bigger project: python flask web server with blog cms, GPIO usage and 3 ways to use a arduino type device on usb cable as extended I/O.

PMS again ( 5/2018 )

what is about PMS inside myBlog, a python/flask/webserver/blogCMS/

newest update
update 07/2019
lately, work with processing ( current rev. 3.5.3 ) and want test that old show again.
+ + download from here and a updated version ( arduino only ) from here
to Raspberry Pi still on
DEBIAN stretch / Linux version 4.19.42-v7+ / on Raspberry Pi 3 Model B Plus Rev 1.3
DEBIAN buster / Linux version 4.19.58-v7+ / on Raspberry Pi 3 Model B Plus Rev 1.3

and using Arduino IDE 1.8.10 Hourly Build 2019/05/21

try the processing 2 sketch, loaded cp5 library,
but the also used library arduino scope
is not usable in processing 3xx any more, so i might need a complete remake,
and try it without any library,
* using my own " registered Button array class "
* and a one scope 3 color beam easy draw points on rectangle background
well, 3 beam in one scope might reduce visibility,
but the new size ( 360 * 512 px ) allows a 1024/2 visualization
i think that means increased visible scope resolution.

now even i call that PMS3 it can be only a 2 beam scope if i use
arduino UNO/Leonardo
because there is not enough RAM for a int[360][3] storage array.
AND for the high-speed sampling anyhow only beam0 is measured/stored.
but i will try again to wring a few bytes out of the code ( variable space )
and test also if a int[2xxx][3] would work?
without the need to change all the rest ( data transport / processing visualization )
shorter beams are acceptable ( 260 instead 360 in one line )
going down to 8bit 256 steps byte storage array is not worth it.

+ + int[260][3] instead int[360,2]
- - so the x axis still has 360 pix and only data for 260
- - and also the min evaluation uses the 260 .. 359 array vals what are 0
- - the ( per beam ) indicated Apin y[V] takes the last array value so also 0
// possibly that all was not the best idea / would need lots of new code to fix //
+ + and also play Win 10 PC and Arduino UNO / instead RPI and Arduino Leonardo
+ + and finished the 3 beam / move / zoom / button menu with RESET

for this test i had to touch the arduino code for the first time in years
( and with this also loose the context to the MASTER CODE as .PDE version for the MAX board )

ok, while i play i have a problem that Win10 not see my Arduino Leonardo ( move it back to RPI ok )
lucky i connect UNO and DUE ok.
new idea is to use the DUE as a signal generator ( DAC0 / DAC1 ) with a "analog ramp" signal
-a- PMS35 on UNO
-b- signal from DUE ( analogWrite 0 .. 1024 )
-c- GND - GND / A0 - DAC0 / A1 - DAC2 / wires

so: what we see here?
UNO tells he measure with 608Hz a array of 360 values,
so the scope screen should be 0.592 sec
we see 6.3 red ramps or 1.4 blue ramps
DUE tells a red ramp is 378ms, a blue ramp is 1891ms
( millis calc and serial print // also confirmed by the arduino monitor timestamp )
so the scope screen should be 2.3 or 2.6 sec ( very much different from scope info )
also the ramp V is 0.56V to 2.77V ( instead 0 .. 3.3V )
so the ramp range is a known DUE DAC limitation ( 0.55 to 2.75V ).

i really need a calibrated signal generator to check the scope.

but first i change for visibility from POINT to LINE ( and strokeWeight(2) )
and show also a PULS signal from DUE to verify 0 .. 3V3 ( yes V= 5V * 683 / 1024 )
and with using the millis info from arduino DUE about the pulses that fits with PMS,
still millis about ramp is OFF.

here now the look same signal other speed setting ( on a UNO ):
the used puls has about 2ms ( on or off time )
fastest: 39kHz ( sample A0 only with special arduino function )

with 24kHz and 2 beam

and a slow setting to see the full ramp 3kHz

here the first code version ( arduino / processing 3.5.3)