Quantcast
Channel: MCS Electronics Forum
Viewing all 20688 articles
Browse latest View live

Share your working BASCOM-AVR code here : RHT03 (DHT22) Sensor : REPLY

$
0
0
Good to hear Alan. The only thing to remember is that with bitwait if the AVR does not get a change then it sits waiting forever using the watchdog would be a good addition. I have just written some more code that works with the sensors using an interrupt input this works well but It has one difficulty in that the main bascom library needs a small change for the Pulsein command I will be posting the code later when I clean it up of print commands and add instructions. Regards Paul

BASCOM-AVR : data loss using inkey #2 with software UART : REPLY

$
0
0
[quote:b105e06bba="six1"]because of this was a very special case... i only used INT to get first char of stream and ended reading by timeout.[/quote:b105e06bba] Whatever you say ;-) [quote:b105e06bba]the master plan wasn't to read byte by byte with int![/quote:b105e06bba] Doesn't make a difference. [quote:b105e06bba]in fact i don't wanted to disturbed by any other int :lol: that's it oder wie die bayern sagen: host me :lol:[/quote:b105e06bba] You do that biz long enough to know, that in AVRs interrupts are globally disabled, as long an interrupt service routine is executed. Iinterrupts are reenabled then, after return from an ISR, or if you explicitly enable them yourself in an ISR, called nested interrupts. But you don't do this nesting thing. Therefore your ISR simply can't disturbed by another interrupt, and that is the reason disabling and reenabling this external interrupt, like you do it, is completely senseless. So, yes, I think I got you, but I'm not sure, whether you got me.

BASCOM-AVR Old versions : [ask] read sms in siemens c55 : REPLY

$
0
0
Hi, C55 only have PDU sms format ? you can try this in BASCOM simulator [code:1:adea869fc7]$regfile = "m128def.dat" $crystal = 8000000 $baud = 19200 Dim I As Byte Dim J As Byte Dim I1 As Byte Dim J1 As Byte Dim Pdu_len As Byte Dim Smslen As Byte Dim K As Byte Dim K1 As Byte Dim K2 As Byte Dim K3 As Byte Dim K4 As Byte Dim Jj As Byte Dim Txt As String * 240 Dim Pdutest As String * 240 Dim X As String * 2 Dim X1 As String * 2 Dim C As String * 1 Declare Sub Txt_pdu() Declare Sub Pdu_txt() Do Print "Type you text here + ENTER>" 'for test sim only ' type at test in simulator UART0 hit enter when done Input Txt 'for test sim only Print "encode PDU" 'for test sim only Call Txt_pdu 'convert text to pdu Print "decode PDU" 'for test sim only Call Pdu_txt ' convert pdu to text Print "DONE" 'for test sim only 'for test sim only Print 'for test sim only Loop 'convert smstxt to pdu Sub Txt_pdu() Jj = Len(txt) Smslen = Jj - 1 Pdutest = "" I1 = 1 J1 = 2 I = 0 J = 1 Do X = Mid(txt , I1 , 1) X1 = Mid(txt , J1 , 1) K1 = Asc(x) K2 = Asc(x1) K = I Mod 8 Shift K1 , Right , K K = 7 - K Shift K2 , Left , K K1 = K1 + K2 Print Hex(k1); Pdutest = Pdutest + Hex(k1) Incr I Incr J Incr J1 Incr I1 If K = 1 Then Incr J Incr I Incr J1 Incr I1 End If Loop Until I > Smslen Print "" End Sub 'convert(pdu) to text Sub Pdu_txt() Jj = 0 I = 0 J = 1 I1 = 1 J1 = 3 Pdu_len = Len(pdutest) Pdu_len = Pdu_len / 2 Do X = Mid(pdutest , I1 , 2) X1 = Mid(pdutest , J1 , 2) K1 = Hexval(x) K2 = Hexval(x1) K = I Mod 7 K3 = K1 'to shift the k1 right If K = 0 Then K1 = K1 And 127 If K = 1 Then K1 = K1 And 63 If K = 2 Then K1 = K1 And 31 If K = 3 Then K1 = K1 And 15 If K = 4 Then K1 = K1 And 7 If K = 5 Then K1 = K1 And 3 If K = 6 Then K1 = K1 And 1 Jj = K + 1 Shift K1 , Left , K K = 7 - K Shift K3 , Right , K If K = 7 Then Print Chr(k1); Else K1 = K1 + K4 Print Chr(k1); End If If K = 1 Then Print Chr(k3); K3 = 0 End If K4 = K3 I1 = I1 + 2 J1 = J1 + 2 Incr I Incr J Loop Until I > Pdu_len Print 'for test sim only End Sub Return[/code:1:adea869fc7]

BASCOM-AVR Old versions : [ask] read sms in siemens c55 : REPLY

$
0
0
do not be shortened again, I just want to when there are incoming sms and message contents "y" then buzer last active? when to send sms I have managed to do it.

BASCOM-AVR : data loss using inkey #2 with software UART : REPLY

$
0
0
takes a while, but NOW i got you :D Ludwig i'm getting older, you're right... Disabling the INT inside the interrupt routine is like filling a full pot :lol: so my code sample can be much, much shorter than shown above! (one line) 8)

Share your working BASCOM-AVR code here : RHT03 (DHT22) Sensor : REPLY

$
0
0
Paul is right in saying you can be stuck in loop if something went wrong. At the time I just wanted to test to see how accurate it was. If you have a small micro and all your Interrupts are busy doing other things you can pole the Port inside a LOOP and use a some variable as a counter (going up to down), when it reaches a desired value you can flag some error and skip the loop.

Share your working BASCOM-AVR code here : Arduino Mega W5100 ethernetshield with SD-card : REPLY

$
0
0
Perhaps a typo, I don't see much difference between these lines [code:1:327179a0cf] #if _crystal <= 8000000 Spcr = &B0101_0000 Spsr.spi2x = 1 #else Spcr = &B0101_0000 Spsr.spi2x = 1 #endif [/code:1:327179a0cf] Have fun Ben Zijlstra

Share your working BASCOM-AVR code here : Arduino Mega W5100 ethernetshield with SD-card : REPLY

$
0
0
yes, you're right ben... corrected this in above code :D

BASCOM-AVR Old versions : [ask] read sms in siemens c55 : REPLY

$
0
0
[code:1:2f3a5bdda4]'init ATE0 AT+CSCS=GSM AT+CPMS=ME AT+CNMI=1,1,0,2 'read sms index 1 AT+CMGR=1 'delete sms 1 AT+CMGD=1[/code:1:2f3a5bdda4]

Share your working BASCOM-AVR code here : RHT03 (DHT22) Sensor : REPLY

$
0
0
In my coding I used both the WDT and Timer0 to make certain that the code did not get hung up waiting for a response. I tested it by putting delays in the loops involved and it seems both the WDT and Timer0 did what I wanted them to do. I believe sometime in the future I am going to use the ATtiny261A to work with the LM34DZ temperature sensor and the Honeywell HIH-4000-003 humidity sensor. The nice thing about the Honeywell sensor is that it comes with calibration data. Alan

Share your working BASCOM-AVR code here : RHT03 (DHT22) Sensor : REPLY

$
0
0
Attached is my program for measuring the liquid level in a septic holding tank and for measuring the temperature and humidity in the tank's headspace. The system uses the following hardware Newhaven LCD, Model NHD-0420D3Z-FL-GBW Parallax Ping ultrasonic sensor Atmel ATtiny4313 microcontroller MaxDetect RHT03 temperature and humidity sensor The coding for using the MaxDetect is based upon work posted by Peter Maroudas on this forum. Alan Hosler

BASCOM-AVR : Calculator percent error rate in the port : NEWTOPIC

$
0
0
Hello. I have long wanted to ask/wrote and kept forgetting, to remember: By default, the menu is set microcontroller "2313def.dat", if you switch to the tab, calculate the percentage of errors ports - all calculated correctly. If you set in the settings menu microcontroller "attiny84.dat", then all the values ​​in the calculator displays the message - "Not possible". I understand that this is not MCU HW UART, but you can somehow add the calculation for the SW UART? Check mark or add more as the thread... Easy to use. :wink: [b:e34181f6c1][color=red:e34181f6c1](BASCOM-AVR version : 2.0.7.6 )[/b:e34181f6c1][/color:e34181f6c1]

BASCOM-AVR : data loss using inkey #2 with software UART : REPLY

$
0
0
[quote:d990fcab94="jwolf"]Thanks for the good hint, Madf, but unfortunately the device I have will reply sending ASCII in multiple lines using <CR> inbetween, which will stop the input routine after the first line (tried that already :D ).[/quote:d990fcab94] You can use: - CONFIG INPUT; - $ TIMEOUT. To configure and control data entry. It really helps on slower and the MCU when transferring large amounts of data.

BASCOM-AVR : data loss using inkey #2 with software UART : REPLY

$
0
0
Hi Madf, as far as I know the <CONFIG INPUT> works only with a real , i.e. a hardware UART. :cry: What I try is to use the software UART. Cheers, Johannes

BASCOM-AVR : EADOGM 128x64: Can GLCDCMD and GLCDDATA be used? : NEWTOPIC

$
0
0
Hi there, I want to work with the Graphic LCD EADOGM 128x64. BASCOM supplies the LIB glcdeadogm128x6.lbx to use this display with the CONIFG GRAPHLCD command. Does anybody know, if the commands GLCDCMD and GLCDDATA are working with this LIB? When I open the lib with a text editor I can see that there are calls to subs "_gwrite_cmd" and "_gwrite_data". Kind regards Roger [b:b7a3a31bee][color=red:b7a3a31bee](BASCOM-AVR version : 2.0.7.6 )[/b:b7a3a31bee][/color:b7a3a31bee]

BASCOM-AVR : data loss using inkey #2 with software UART : REPLY

$
0
0
Dear all, I would like to thank you for the discussion giving many useful hints and tips. Finally I found out what was preventing my Inkey - loop from receiving the first bytes of the replied message: [code:1:8043265eb2]Dim Tx_buf(128) As Byte Dim Command As String * 127 At Tx_buf Overlay Input "Command: " , Command 'command via terminal Command = Command + Chr(13) 'append CR X = len(command) Printbin #1 , Tx_buf(1) , X 'output x command bytes[/code:1:8043265eb2] This goes back to one of the questions from MWS - yes I know the difference between print and printbin. As you can see I use the overlay of the string variable "Command" on a Byte Array " Tx_buf". So I can send easily Bytes that represent the characters of a string in ASCII. I like this method. :) Finally I need to add a <CR> at the end, because this is required from my device I want to communicate with. So the only explanation I have is that this code above does not exactly do what I want it to do in the sense that it takes longer than expected before my receiving loop can start. So as a consequence I miss the first ca. 10 Bytes when receiving the reply to the command. Also I got the impression that too many bytes are sent - my device returns then " bad command" . What I now did and what actually solved my problem was to use as advised the statement <print #1 , Command ; Chr(13) ;> and it works fine! :D Thanks again! Cheers, Johannes

BASCOM-AVR : data loss using inkey #2 with software UART : REPLY

$
0
0
[quote:cd486b6788="jwolf"]as far as I know the <CONFIG INPUT> works only with a real , i.e. a hardware UART. :cry: What I try is to use the software UART.[/quote:cd486b6788] I'm doing a project, it all works on the software UART - checked. :wink:

BASCOM-AVR : EADOGM 128x64: Can GLCDCMD and GLCDDATA be used? : REPLY

$
0
0
yes it should work. it calls either _gwrite_cmd or _gwrite_data

BASCOM-AVR : EADOGM 128x64: Can GLCDCMD and GLCDDATA be used? : REPLY

$
0
0
Thanks Mark for fast answer :-) Kind regards Roger

BASCOM-AVR : data loss using inkey #2 with software UART : REPLY

$
0
0
[quote:f5a83aa794="jwolf"][code:1:f5a83aa794]Printbin #1 , Tx_buf(1) , X 'output x command bytes[/code:1:f5a83aa794][/quote:f5a83aa794] This use of printbin is wrong, checking the help you see that the length parameter has to be a constant number, which is separated by the leading array by a semicolon. What you did here makes Bascom send the complete array, followed by one byte of X.
Viewing all 20688 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>