Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:20 22 Nov 2024 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 : PicoMite V6.00.00 release candidates - all versions

     Page 22 of 22    
Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6089
Posted: 10:49pm 18 Nov 2024
Copy link to clipboard 
Print this post

What was wrong with leaving r as a long long int ?
if( ( ( ((r >> 8) & 0xff) + ((r >> 16) & 0xff) + ((r >> 24) & 0xff) + ((r >> 32) & 0xff) ) & 0xff) != (r & 0xff)) goto error_exit;                                           // returning temperature

VK7JH
MMedit   MMBasic Help
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 482
Posted: 10:58pm 18 Nov 2024
Copy link to clipboard 
Print this post

Just something to watch out for - in some systems, bit shifting right does not necessarily set the most significant bit to 0.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6089
Posted: 12:48am 19 Nov 2024
Copy link to clipboard 
Print this post

  disco4now said  We were here for the DHT22 in 2015 on the micromite.I think its a combination of Temp and Humid that causes an overflow when the adding the 4 bytes of data to calculate the checksum.

MM2: DHT22 Is there an issue?


Yes, that makes sense.
I changed my test to include the checksum before masking with &hFF
Whenever the checksum is over 255, MMBasic returns 1000

0000001001110101000000001011100000101111        303
18.4   62.9
1000   1000

0000001001000010000000001011011111111011        251
18.3   57.8
18.3   57.8

0000001000111001000000001011011111110010        242
18.3   56.9
18.3   56.9

0000001000110001000000001011011111101010        234
18.3   56.1
18.3   56.1

0000001000101100000000001011011111100101        229
18.3   55.6
18.3   55.6

0000001000100101000000001011011111011110        222
18.3   54.9
18.3   54.9

0000001110110101000000001011100101110001        369
18.5   94.9
1000   1000

0000001011011011000000001011100010010101        405
18.4   73.1
1000   1000

0000001011001101000000001011100010000111        391
18.4   71.7
1000   1000

0000001010100110000000001011100001100000        352
18.4   67.8
1000   1000


Jim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9084
Posted: 08:33am 19 Nov 2024
Copy link to clipboard 
Print this post

Jim

Can you print out the received data as bytes when it passes and when it fails then I can check what is happening and fix - thanks
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6089
Posted: 09:00am 19 Nov 2024
Copy link to clipboard 
Print this post

Having trouble getting many passes tonight.
5 bytes in order followed by calculated values then MMBasic output.


1      172     0       193     110    fail
19.3   42.8
1000   1000

1      170     0       192     107    fail
19.2   42.6
1000   1000

1      167     0       193     105    fail
19.3   42.3
1000   1000

1      181     0       192     118    fail
19.2   43.7
1000   1000

2      94      0       193     33     fail
19.3   60.6
1000   1000

1      238     0       193     176    fail
19.3   49.4
1000   1000

1      200     0       193     138    fail
19.3   45.6
1000   1000

1      187     0       193     125    fail
19.3   44.3
1000   1000

1      183     0       193     121    fail
19.3   43.9
1000   1000

1      176     0       193     114    fail
19.3   43.2
1000   1000

1      174     0       192     111    fail
19.2   43
1000   1000

2      122     0       194     62     fail
19.4   63.4
1000   1000

2      11      0       193     206    Pass
19.3   52.3
19.3   52.3

1      209     0       194     148    fail
19.4   46.5
1000   1000

1      187     0       193     125    fail
19.3   44.3
1000   1000

1      177     0       193     115    fail
19.3   43.3
1000   1000

2      216     0       194     156    fail
19.4   72.8
1000   1000

2      41      0       194     237    Pass
19.4   55.3
19.4   55.3

1      219     0       194     158    fail
19.4   47.5
1000   1000

1      194     0       194     133    fail
19.4   45
1000   1000

1      187     0       193     125    fail
19.3   44.3
1000   1000

1      184     0       194     123    fail
19.4   44
1000   1000

3      82      0       195     24     fail
19.5   85
1000   1000

2      18      0       195     215    Pass
19.5   53
19.5   53

1      211     0       194     150    fail
19.4   46.7
1000   1000


Assuming you do need the uint8_t stuff,
I added an extra pair of brackets to your code but not in a position to try it.
if( ( (uint8_t)(( ((r >> 8) & 0xff) + ((r >> 16) & 0xff) + ((r >> 24) & 0xff) + ((r >> 32) & 0xff) ) & 0xff) ) != (uint8_t)(r & 0xff)) goto error_exit;


Jim
VK7JH
MMedit   MMBasic Help
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2108
Posted: 12:29am 20 Nov 2024
Copy link to clipboard 
Print this post

math scale samples!(),239,samples!()'scale to 240 pixel height
changed to  math scale samples!(),139,samples!()'scale to 140 pixel height
and it's the same, 239
PicoMiteVGA MMBasic USB Edition  6.00.00RC15
OPTION SERIAL CONSOLE COM2,GP8,GP9
OPTION AUTORUN  ON
OPTION FLASH SIZE 4194304
OPTION COLOURCODE ON
OPTION KEYBOARD UK, 0, 0, 600, 150
OPTION CPUSPEED (KHz) 378000
OPTION DISPLAY 30, 53
OPTION SDCARD GP13, GP10, GP11, GP12
OPTION AUDIO GP0,GP1', ON PWM
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2129
Posted: 02:13am 20 Nov 2024
Copy link to clipboard 
Print this post

Jim and Peter
To help find the condition that causes the Humid error here is a DHT emulator that  lets you set the values of the data bytes independently.
The variable q can be used to increment the bytes on each response.
' "DHT Test Emulator 01.bas"
'
SetPin GP1, DIn, pullup 'Diode A to GP1, K to GP0 3.3k to 3.3V and link to other Pico for Humid.

Dim integer a(83), b1, b2, b3, b4, b5, word, n, m, q=60

Do
 Math Set 50, a() : a(0)=80 : a(1)=80

 b1=q : b2=q : b3=q : b4=63
 b5 = (b1+b2+b3+b4) And 255 'make checksum
 word = (b1<<32) + (b2<<24) + (b3<<16) + (b4<<8) + b5
 m=0 : Print Bin$(word,40)

 For n=81 To 2 Step -2
   a(n) = 26 + 44 * ((word >> m) And 1)
'    Print n,m,a(n)
   Inc m
 Next

 Print "Waiting to receive HUMID command (either type 0 or 1)"

 Do While Pin(GP1) : Loop
 Pin(GP0) = 1
 SetPin GP0, DOut 'Diode K to gp0, A to GP1,
 Do : Loop Until Pin(GP1)

 Device BitStream GP0, 83, a()
 Pin(gp0)=1
 SetPin gp0, off
 Inc q
 Print "Sent "; b1, b2, b3, b4, b5
Loop
End

Saved 1035 bytes
0011110000111100001111000011111111110011
Waiting to receive HUMID command (either type 0 or 1)
Sent  60         60      60      63      243
0011110100111101001111010011111111110110
Waiting to receive HUMID command (either type 0 or 1)
Sent  61         61      61      63      246
0011111000111110001111100011111111111001
Waiting to receive HUMID command (either type 0 or 1)
Sent  62         62      62      63      249
0011111100111111001111110011111111111100
Waiting to receive HUMID command (either type 0 or 1)
Sent  63         63      63      63      252
0100000001000000010000000011111111111111
Waiting to receive HUMID command (either type 0 or 1)
Sent  64         64      64      63      255
0100000101000001010000010011111100000010
Waiting to receive HUMID command (either type 0 or 1)
Sent  65         65      65      63      2
0100001001000010010000100011111100000101
Waiting to receive HUMID command (either type 0 or 1)
Sent  66         66      66      63      5
0100001101000011010000110011111100001000
Waiting to receive HUMID command (either type 0 or 1)
Sent  67         67      67      63      8
0100010001000100010001000011111100001011
Waiting to receive HUMID command (either type 0 or 1)
Sent  68         68      68      63      11
0100010101000101010001010011111100001110
Waiting to receive HUMID command (either type 0 or 1)
Sent  69         69      69      63      14
0100011001000110010001100011111100010001
Waiting to receive HUMID command (either type 0 or 1)
>
and the response of Humid
> do :humid gp1,t,h,0 :? t,h :pause 1000 : loop
1542.3  1542
1567.9  1567.7
1619.1  1619.1
1644.7  1644.8
1000    1000
1000    1000
1000    1000
1000    1000
1000    1000
>

Edited 2024-11-20 12:16 by phil99

Footnote added 2024-11-20 13:43 by phil99
Any combination of bytes that causes the checksum to rollover to zero produces "1000 1000" so Gerry's diagnosis is correct.

Footnote added 2024-11-20 16:47 by phil99
A one pin version that doesn't need the diode or pullup resistor.
DHT Test Emulator 04.zip
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2129
Posted: 03:06am 20 Nov 2024
Copy link to clipboard 
Print this post

Stan, perhaps Math Window is what you need. Math Scale just multiplies the values by a constant. eg
> clear
> dim samples(24) : for n=0 to 24 : samples(n)=n : next : math v_print samples()
  0.0000,    1.0000,    2.0000,    3.0000,    4.0000,    5.0000,    6.0000,    7.0000,    8.0000,    9.0000,   10.0000,   11.0000,   12.0000,   13.0000,   14.0000,   15.0000,   16.0000,   17.0000,   18.0000,   19.0000,   20.0000,   21.0000,   22.0000,   23.0000,   24.0000
> math scale samples(), 0.5, samples() : math v_print samples()
  0.0000,    0.5000,    1.0000,    1.5000,    2.0000,    2.5000,    3.0000,    3.5000,    4.0000,    4.5000,    5.0000,    5.5000,    6.0000,    6.5000,    7.0000,    7.5000,    8.0000,    8.5000,    9.0000,    9.5000,   10.0000,   10.5000,   11.0000,   11.5000,   12.0000
>

> MATH WINDOW samples(), 0, 120, samples() :math v_print samples()
  0.0000,    5.0000,   10.0000,   15.0000,   20.0000,   25.0000,   30.0000,   35.0000,   40.0000,   45.0000,   50.0000,   55.0000,   60.0000,   65.0000,   70.0000,   75.0000,   80.0000,   85.0000,   90.0000,   95.0000,  100.0000,  105.0000,  110.0000,  115.0000,  120.0000
>

Edited 2024-11-20 13:09 by phil99
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6089
Posted: 06:11am 21 Nov 2024
Copy link to clipboard 
Print this post

I do have a working tool-chain for MMBasic V5.07.08 so I added Peters line from RC15 to it and sure enough, the DHT22 call failed with any overflow.
I then changed to Peter's suggestion
if( ( (uint8_t)( ((r >> 8) & 0xff) + ((r >> 16) & 0xff) + ((r >> 24) & 0xff) + ((r >> 32) & 0xff) ) ) != (uint8_t)(r & 0xff)) goto error_exit;

and the DHT22 now works again.

I am not sure why the addition test is need when a similar one exists a few lines earlier, but there is much I don't understand...

Jim
VK7JH
MMedit   MMBasic Help
 
GAVI
Newbie

Joined: 20/11/2024
Location: Italy
Posts: 3
Posted: 08:05am 21 Nov 2024
Copy link to clipboard 
Print this post

Hi everyone, I have two problems:
1) with Raspberry YD-RP2040 everything seems to work but MMCC is unable to transfer files larger than 98k bytes.
the other Raspberries work fine.
2) the MSGBOX("a","b","c") function only works up to MMbasic 5.08, the versions I tried (6.00RC8 and RC15) return the error ERROR: INVALID CHARACTER
Thanks for the work you are doing.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6760
Posted: 10:38am 21 Nov 2024
Copy link to clipboard 
Print this post

Hi Gavi,
Check the CPU speed that you are using for YD-RP2040. They won't run as fast as the Pico and strange things may happen. I've had them running at about 250MHz but no higher (they would run VGA). Apart from that the CPU is the same. It seems to be that the 16MB flash is too slow as the 4MB boards that are similar to the YD-RP2040 are ok.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
GAVI
Newbie

Joined: 20/11/2024
Location: Italy
Posts: 3
Posted: 11:33am 21 Nov 2024
Copy link to clipboard 
Print this post

Thanks for the reply, I'll try some more tests.
the problem of the MSGBOX function also occurs on Rasperry Pico.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2129
Posted: 11:34am 21 Nov 2024
Copy link to clipboard 
Print this post

Tried the MsgBox() example in the 5.08 manual on 6.0RC15, standard PicoMite LCD.
At CPU speeds 133 to 400MHz:-
Error : Invalid character:
>
Edit
Same at 64MHz.
Edited 2024-11-21 22:04 by phil99
 
GAVI
Newbie

Joined: 20/11/2024
Location: Italy
Posts: 3
Posted: 02:12pm 21 Nov 2024
Copy link to clipboard 
Print this post

hi phil99, if you try to install version 5.08 you will see that it works correctly
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9084
Posted: 02:21pm 21 Nov 2024
Copy link to clipboard 
Print this post

V6.00.00RC16

Fixes the bugs

MSGBOX
HUMID for DHT22
Missing cursor in EDIT


PicoMiteRP2350V6.00.00RC16.zip

PicoMiteRP2040V6.00.00RC16.zip
 
     Page 22 of 22    
Print this page


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

© JAQ Software 2024