If you have a laser rangefinger that is not either of those, please post!
Also, if you have questions about those two pages, please ask. When I did those they made sense at the time and appeared to work, but I don't know if anybody else tried them yet. There may be errors.
This is really interesting. What is INA226 used for in an application? For example, can we measure current and voltage to a DC motor, and determine how much load the motor is seeing as any given measurement?
Changing shunt-resistor get different measure-range and resolution.
This module use 0.025ohm; Resolution=0.1mA Range=-3.2768A to +3.2767A
If shunt-resistor is 0.002ohm; Resolution=1mA Range=-32.768A to +32.767A
This can connect both Hi-side and Lo-side for motor,etc.
Application are power monitor,motor current monitor, etc.
shunt-voltage,Bus voltage,power can issue limit-alert to alert-pin.
This module cost 1000yen(about $8).
I had written code about Charlieplexing in Novenber 2014.
Date is unknown. I seems this forum delete date.
I found out there is bug in Charlieplexing_8x8Matrix_0.3_1.f
I re-write code and summary.
But summary is bigger than 2M.
Cannot upload.
I upload only "Charlieplexing_8x8Matrix_0.3_2".
Re-wrote word are 'matrix_Charlie_fth' and '_matrix_Charlie_asm'.
Caskaz,
What are you trying to do? Are you using a touch panel and trying to determine where it is pressed?
If so, you can use the props sigma delta to do this but may not be as precise as you require. IIRC I posted pasm code in a thread a few years ago. Not sure if I put it in obex.
I wrote code for TouchScreenController(ADS7843) by using SPI-communication.
When pen touched on touchscreen, measurment start.
Data(x,y) are average-value[8samples].
fl
{
TouchScreen Controller(ADS7843)
PropForth5.5
2015/12/30 13:19:29
----------------
3V3-- |Vref Vcc| -- 3V3 -----------
P5 -----> |cs X+| --------- | |
P6 -----> |clk X-| --------- |TouchScreen|
P7 -----> |din ADS7843 Y+| --------- | |
P8 <----- |dout Y-| --------- | |
3V3 | | -----------
| | |
10k | |
| | |
P9 <----- |PENIRQ |
| GND |
----------------
|
GND
TouchPosition(X,Y) is averaged by sampled 8 times.
}
\ -------------------------------------------------------
\ Constants
\ -------------------------------------------------------
5 wconstant cs
6 wconstant clk
7 wconstant din
8 wconstant dout
1 dout lshift constant doutm
9 wconstant penirq
1 penirq lshift constant penirqm
\ A/D selection
9 wconstant Ydata
hD wconstant Xdata
hA wconstant Aux1
hE wconstant Aux2
\ Resolution
0 wconstant 12bit
1 wconstant 8bit
\ Single/Differential
0 wconstant diff
1 wconstant single
\ PowerDown selection
0 wconstant enablePD
1 wconstant disablePD
8 wconstant average
\ -------------------------------------------------------
\ Variables
\ -------------------------------------------------------
wvariable cont_X
wvariable cont_Y
wvariable contAux1
wvariable contAux2
\ -------------------------------------------------------
\ Main
\ -------------------------------------------------------
\ Set clk to Hi
\ ( -- )
: clk_h clk pinhi ;
\ Set clk to Lo
\ ( -- )
: clk_l clk pinlo ;
\ Set din to Hi
\ ( -- )
: din_h din pinhi ;
\ Set din to Lo
\ ( -- )
: din_l din pinlo ;
\ Set control byte(X and Y) for TouchScreen
\ ( n1 n2 n3 -- ) n1:mode n2:single/differential n3:PowerDown
: setTSC
swap 2 lshift or
swap 3 lshift or
dup
Ydata 4 lshift or cont_Y W!
Xdata 4 lshift or cont_X W!
;
\ Set control byte(Aux1 and Aux2) for Aux
\ ( n1 n2 n3 -- ) n1:mode n2:single/differential n3:PowerDown
: setAux
swap 2 lshift or
swap 3 lshift or
dup
Aux1 4 lshift or contAux1 W!
Aux2 4 lshift or contAux2 W!
;
\ SPI communication
\ ( n1 -- n2 ) n1;control byte n2:data
: 24bitSPI
cs pinlo
0 swap \ ( 0 n1 )
d16 lshift h800000 \ ( 0 n1 h800000 )
d24 0 do
\ transmitt
2dup \ ( 0 n1 h800000 n1 h800000 )
and
if din_h else din_l then
clk_h \ Send 1bit to din
\ receive
rot \ ( n1 h800000 0 )
ina COG@ doutm and
if 1 or then 1 lshift rot2 \ Receive 1bit from dout
clk_l
1 rshift
loop
2drop
1 rshift
cs pinhi
;
\ Get A/D 1data
\ ( n1 -- n2 ) n1;control byte n2:data
: rdA/D
dup 24bitSPI \ ( n1 [received data] )
swap 8 and \ ( [received data] 1/0 )
if
\ 8bit mode
7 rshift hFF and
else
\ 12bit mode
3 rshift hFFF and
then \ ( n2 )
;
\ Get Touch position
\ ( -- )
: rdTouch
0 \ initial sum for Y
average 0 do
cont_Y W@ rdA/D
+
loop
average u/
0 \ initial sum for X
average 0 do
cont_X W@ rdA/D
+
loop
average u/
;
: demo
\ Set data for TouchScreenController
12bit diff enablePD setTSC
\ Set output port
cs pinhi cs pinout clk pinout din pinout
begin
begin ina COG@ penirqm and 0= until \ Wait until pen-touch is detected
rdTouch ." X:" . ." Y:". cr
fkey? swap drop
until
\ Set data for TouchScreenController
8bit diff enablePD setTSC
begin
begin ina COG@ penirqm and 0= until \ Wait until pen-touch is detected
rdTouch ." X:" . ." Y:". cr
fkey? swap drop
until
;
\ Time to get X-position
\ ( -- )
: test2 cnt COG@ cont_X W@ rdA/D cnt COG@ nip swap - dup . ." ticks " d80 u/ . ." usec" ;
I wrote TouchScreen Controller' code by using 2cog.
Cog6 send control-byte and clock.
Cog0 receive A/D conversion data from ADS7843.
8data need 136clocks(12bit mode), 104clocks(8bit mode).
Above SPI code, it need 24clock(12bit mode/8bit mode).
It need 196clock at 8data.
fl
{
TouchScreen Controller(ADS7843)
PropForth5.5
2016/01/01 12:28:21
----------------
3V3-- |Vref Vcc| -- 3V3 -----------
P5 -----> |cs X+| --------- | |
P6 -----> |clk X-| --------- |TouchScreen|
P7 -----> |din ADS7843 Y+| --------- | |
P8 <----- |dout Y-| --------- | |
3V3 | | -----------
| | |
10k | |
| | |
P9 <----- |PENIRQ |
P10 <---- |busy |
| GND |
----------------
|
GND
}
\ -------------------------------------------------------
\ Constants
\ -------------------------------------------------------
5 wconstant cs
1 cs lshift constant csm
6 wconstant clk
1 clk lshift constant clkm
7 wconstant din
8 wconstant dout
1 dout lshift constant doutm
9 wconstant penirq
1 penirq lshift constant penirqm
d10 wconstant busy
1 busy lshift constant busym
\ A/D selection
9 wconstant Ydata
hD wconstant Xdata
hA wconstant Aux1
hE wconstant Aux2
\ Mode
0 wconstant 12bit
1 wconstant 8bit
\ Single/Differential
0 wconstant diff
1 wconstant single
\ PowerDown selection
0 wconstant enablePD
3 wconstant disablePD
8 wconstant average
\ -------------------------------------------------------
\ Variables
\ -------------------------------------------------------
wvariable cont_X
wvariable cont_Y
wvariable posX
wvariable posY
wvariable aveVal
\ -------------------------------------------------------
\ Main
\ -------------------------------------------------------
\ Output clk-pulse
\ ( -- )
: clk_pulse clk pinhi clk pinlo ;
\ Set din to Hi
\ ( -- )
: din_h din pinhi ;
\ Set din to Lo
\ ( -- )
: din_l din pinlo ;
\ Set control byte(X and Y) for ADS7843
\ ( n1 n2 n3 -- ) n1:mode n2:single/differential n3:PowerDown
: setTSC
swap 2 lshift or
swap 3 lshift or
dup
Ydata 4 lshift or cont_Y W!
Xdata 4 lshift or cont_X W!
;
\ Wait until busy fall down
\ ( -- )
: waitBusy
begin ina COG@ busym and until
begin ina COG@ busym and 0= until
;
: waitBusy
busym busym waitpeq \ Wait until busy goes to Hi
busym busym waitpne \ Wait until busy goes to Lo
;
\ Read A/D conversion data
\ ( n1 -- n2 ) n1:8 or 12 n2:A/D conversion value
: rdA/D
0 \ Initial value
swap 0 do
1 lshift
clkm clkm waitpeq \ Wait until clk go to Hi
ina COG@ doutm and
if 1 or then
clkm clkm waitpne \ Wait until clk go to Lo
loop
;
\ Get average value
\ ( -- n1 ) n1:average value
: rdTS
begin
begin ina COG@ csm and 0= until \ Wait until cs goes to Lo
0 \ Initial average value
average 0 do
waitBusy \ Wait until busy fall down
cont_X W@ 8 and \ Check mode
if 8 else d12 then
rdA/D \ Get A/D value
+
loop
8 u/ aveVal W!
begin ina COG@ csm and until \ Wait until cs goes to Hi
0 until
;
\ Send controlByte(8bit) and only clock-pulse
\ ( n1 -- ) n1:control byte
: sendData
h80
8 0 do
2dup and
if din_h else din_l then
clk_pulse
1 rshift
loop
2drop
\ Send clock
cont_X W@ 8 and \ Check mode
if 4 else 8 then
0 do
clk_pulse
1 1 * drop \ Dummy delay
loop
;
\ Send extra clock
\ ( -- )
: extraCLK
cont_X W@ 8 and \ Check mode(8bit or 12bit)
if d12 else d16 then
0 do
clk_pulse
1 1 * drop \ Dummy delay
loop
;
\ Display (X.Y)
\ Cog6 send control-byte and extra clock and Cog0 read A/D conversion data
\ ( -- )
: demo
\ Set data for TouchScrenn
12bit diff enablePD setTSC
cs pinhi cs pinout clk pinout din pinout
c" rdTS" 0 cogx
begin
penirqm penirqm waitpne \ Check touch
\ --- X ---
cs pinlo \ Activate cs
\ X
average 0 do
\ Send control-byte
cont_X W@ sendData
loop
extraCLK
aveVal W@ posX W!
cs pinhi \ Deactivate cs
\ --- Y ---
cs pinlo \ Activate cs
\ Y
average 0 do
\ Send control-byte
cont_Y W@ sendData
loop
extraCLK
aveVal W@ posY W!
cs pinhi \ Deactivate cs
." X:" posX W@ . ." Y:" posY W@ . cr
fkey? swap drop
until
0 cogreset
;
\ Display time for X-position(sample:8 data) and (X.Y)
\ ( -- )
: demo1
\ Set data for TouchScrenn
12bit diff enablePD setTSC
cs pinhi cs pinout clk pinout din pinout
c" rdTS" 0 cogx
begin
penirqm penirqm waitpne \ Check touch
\ --- X ---
cnt COG@
cs pinlo \ Activate cs
\ X
average 0 do
\ Send control-byte
cont_X W@ sendData
loop
extraCLK
aveVal W@ posX W!
cs pinhi \ Deactivate cs
cnt COG@ swap - .
\ --- Y ---
cs pinlo \ Activate cs
\ Y
average 0 do
\ Send control-byte
cont_Y W@ sendData
loop
extraCLK
aveVal W@ posY W!
cs pinhi \ Deactivate cs
." X:" posX W@ . ." Y:" posY W@ . cr
fkey? swap drop
until
0 cogreset
;
Today is her Birthday.(January 2)
She is 12 years old.
Hi,
I have a GPS module with serial NMA0183 output ( 4800 8n1 ) and a propeller board with propforth installed
My idea is to read the NMEA data from the propeller serial interface and display it on a LCD, but the serial port is normally used by the terminal session of propforth. Is it possible to detect a NMEA sentence like:
$GPGGA,191410,4735.5634,N,00739.3538,E,1,04,4.4,351.5,M,48.0,M,,*45
in the input stream and extract and store the data in table for example ?
Any ideas ?
Hi,
I have a GPS module with serial NMA0183 output ( 4800 8n1 ) and a propeller board with propforth installed
My idea is to read the NMEA data from the propeller serial interface and display it on a LCD, but the serial port is normally used by the terminal session of propforth. Is it possible to detect a NMEA sentence like:
$GPGGA,191410,4735.5634,N,00739.3538,E,1,04,4.4,351.5,M,48.0,M,,*45
in the input stream and extract and store the data in table for example ?
Any ideas ?
Sven
Alright then, closest I could help you here is a little bit that I did in Tachyon Forth in this post but have a look through the thread. Basically it involves telling Tachyon that the comma is a delimiter and to essentially post process the string.
Did you ever figure out the random issue with your PID demo?
One thing I ran across (yet again) that causes random reset:
If my diagnostic code (running on cog 6) prints too fast, it will choke the serial link.
That is, if I am printing a page worth of characters to the terminal screen, but I don't leave enough time between pages, eventually something will crash. I had a delay of 10 ms (10 delms) between screens and it would randomly crash after several hours. I changed the diagnostic to display once every second, and it now runs for days and hasn't crashed again.
Comments
This is stuff I have for both:
this page https://code.google.com/p/propforth/wiki/LIDARLite
for I2C (faster communications but not serial)
and this page https://code.google.com/p/propforth/wiki/SF02LaserRangeFinder
for serial (easier if you know only serial and not I2C)
If you have a laser rangefinger that is not either of those, please post!
Also, if you have questions about those two pages, please ask. When I did those they made sense at the time and appeared to work, but I don't know if anybody else tried them yet. There may be errors.
Used only sound part of code"SimpleGame2_0.1" below;
http://forums.parallax.com/discussion/146693/propforth-v5-5-is-available-for-download/p18
[video] [/video]
Shunt-resistor is 0.025ohm.
Using i2c_utility_0.4_1.f.
i2c_utility_0.4_1.f. modified only comments from i2c_utility_0.4.f.
INA226's reading from I2C use 'i2c_rd_multi'.
(PDF procedure is different.)
I found out 'i2c_wr_multi is also available.
I will update code later.
Changing shunt-resistor get different measure-range and resolution.
This module use 0.025ohm; Resolution=0.1mA Range=-3.2768A to +3.2767A
If shunt-resistor is 0.002ohm; Resolution=1mA Range=-32.768A to +32.767A
This can connect both Hi-side and Lo-side for motor,etc.
Application are power monitor,motor current monitor, etc.
shunt-voltage,Bus voltage,power can issue limit-alert to alert-pin.
This module cost 1000yen(about $8).
Date is unknown. I seems this forum delete date.
I found out there is bug in Charlieplexing_8x8Matrix_0.3_1.f
I re-write code and summary.
But summary is bigger than 2M.
Cannot upload.
I upload only "Charlieplexing_8x8Matrix_0.3_2".
Re-wrote word are 'matrix_Charlie_fth' and '_matrix_Charlie_asm'.
Using TouchScreen under noise;
1) Using capacitance
2) Averasing value(x,y)
3) Measuring TouchPressure, Use it as threshold value
This time, measured TouchPress.
This use float.f
4096 is resolution of ADC(MCP3204).
I'm going to practice Github.
I uploaded "Charlieplexing".
https://github.com/caskaz/PropForth5.5
I erase someday because of practice.
What are you trying to do? Are you using a touch panel and trying to determine where it is pressed?
If so, you can use the props sigma delta to do this but may not be as precise as you require. IIRC I posted pasm code in a thread a few years ago. Not sure if I put it in obex.
When pen touched on touchscreen, measurment start.
Data(x,y) are average-value[8samples].
Cog6 send control-byte and clock.
Cog0 receive A/D conversion data from ADS7843.
8data need 136clocks(12bit mode), 104clocks(8bit mode).
Above SPI code, it need 24clock(12bit mode/8bit mode).
It need 196clock at 8data.
Today is her Birthday.(January 2)
She is 12 years old.
STTS751 is SMBus device.
I have a GPS module with serial NMA0183 output ( 4800 8n1 ) and a propeller board with propforth installed
My idea is to read the NMEA data from the propeller serial interface and display it on a LCD, but the serial port is normally used by the terminal session of propforth. Is it possible to detect a NMEA sentence like:
$GPGGA,191410,4735.5634,N,00739.3538,E,1,04,4.4,351.5,M,48.0,M,,*45
in the input stream and extract and store the data in table for example ?
Any ideas ?
Sven
I don't have idea about GPS.
I upload SerialCommunication documents to Github.
https://github.com/caskaz/PropForth5.5
Alright then, closest I could help you here is a little bit that I did in Tachyon Forth in this post but have a look through the thread. Basically it involves telling Tachyon that the comma is a delimiter and to essentially post process the string.
The only tricky bit is that the number we supply for baud rate gets multiplied by 4 (to allow a higher max baud rate without reworking the kernel)
so to have baud 4800 using caskz's code you would change the line to :
c" 26 27 d1200 serial" 5 cogx
When PID-operating finish, PropForth don't reply prompt.
I made FET-drive curcuit board and Photo-interupt sensor board.
I put capatitor in 12V.
This is caused by hardware or code?
Drawing graph by sending data from PropForth to Processing.
Did you ever figure out the random issue with your PID demo?
One thing I ran across (yet again) that causes random reset:
If my diagnostic code (running on cog 6) prints too fast, it will choke the serial link.
That is, if I am printing a page worth of characters to the terminal screen, but I don't leave enough time between pages, eventually something will crash. I had a delay of 10 ms (10 delms) between screens and it would randomly crash after several hours. I changed the diagnostic to display once every second, and it now runs for days and hasn't crashed again.
What is random reset?
You try PID_test.f inside PID1_Exercize on github?
Position get from encoder by connecting motor and it.