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

BASCOM-ARDUINO : Arduino Nano with I2c LCD and backlight : REPLY

$
0
0
really amazing. Smart programming of the text LCD. I like it :D

BASCOM-ARDUINO : Arduino Nano with I2c LCD and backlight : REPLY

$
0
0
In the truth the shag - poaching horse, is from Bascom application notes (one made by Radawan) I only make this video to show someone else on polish forum that this is really easy to achieve :D And also post it here because used library is from this topic. Finally i was think that show simple "Hello world" will not be interesting as this horse hahaha :D

BASCOM-ARDUINO : Arduino Nano with I2c LCD and backlight : REPLY

$
0
0
thanks for pointing that out. I knew about clever programming of LCD. But i forgot about this AN. I had no idea that it would look that good. A video makes all the difference.

Share your working BASCOM-AVR code here : NOKIA-1100 library : REPLY

$
0
0
Sorry to use this way to contact you , but I listened in the radio, the subway crash in St-Peterburg. I See in your profil you are living in this city. so - Are you safe ? -I have a thought for each of your compatriots We will visit St-Peterburg in june with my friendship JP

BASCOM-AVR : Do something when var changes : NEWTOPIC

$
0
0
Dear MCSelec community, the purpose is that I want to change 1 var when I press the button (Incr) and I want to use CLS if that var changes. Only once. So like if var C is not same as C in the previous cycle, or also maybe if one condition was true, but now it is not anymore and then again when it comes true. If I put cls in the code, it would clear all the time and it is annoying. At the moment I used: [code:1:ae86e80975] Config Timer0 = Timer , Prescale = 64 On Timer0 Casovnik Enable Timer0 Casovnik: If C = 1 OR C = 2 OR C = 3 OR C = 4 then 'C is the var I change by pressing the button' Cas4 = Cas4 + 1 If Cas4 >= 201 Then Cas4= 0 End If end if If Cas4 = 200 then D = C 'D is only there so I have delay for cls' If D <> C and Cas4 = 50 then cls [/code:1:ae86e80975] the problem is that sometime is working ok and sometimes not as it should or I would want to. If I scroll menu fast it doesn't cls. I can post whole code but it is quite big and it is hard to find stuff. [b:ae86e80975][color=red:ae86e80975](BASCOM-AVR version : 2.0.7.8 )[/b:ae86e80975][/color:ae86e80975]

Share your working BASCOM-AVR code here : NOKIA-1100 library : REPLY

$
0
0
It's very sad. Thanks, I'm safe. --- You are always welcome in St. Petersburg. Don't worry about your safety - our city is very peaceful.

BASCOM-AVR : Do something when var changes : REPLY

$
0
0
I was try to understand question but..I dont understant it maybe. But I have a tip: [code:1:e092b17c65]Dim Value As Byte, Old_value As Byte If Old_value <> Value Then ' do wanted staff '... Old_value = Value ' alignment values for purpose of doing this only once End If[/code:1:e092b17c65]

BASCOM-AVR : Do something when var changes : REPLY

$
0
0
[quote:639bc75bf0="EDC"]I was try to understand question but..I dont understant it maybe. But I have a tip: [code:1:639bc75bf0]Dim Value As Byte, Old_value As Byte If Old_value <> Value Then ' do wanted staff '... Old_value = Value ' alignment values for purpose of doing this only once if they differ End If[/code:1:639bc75bf0][/quote:639bc75bf0] Interrupts are enabled so I think this won't work. For example: [code:1:639bc75bf0] Config Timer0 = Timer , Prescale = 64 On Timer0 Casovnik Enable Timer0 Casovnik: Cas1 = Cas1 + 1 If Cas1 >= 490 Then Cas1= 0 End If If Cas1 = 1 then Incr A If A => 10 then A=0 End if[/code:1:639bc75bf0] How can I say if pina.0 = 0 then A = 1, but even if pina.0 is still 0 the cycle would incr A with pina.0 staying 0. If I say if pina.0=0 then A = 1 incr A So I have a problem because it will stay 1 because condition is still true. I need so when I press button I will incr C and for each number of C I have a menu on LCD that is shown. But I want to cls LCD only when C increases. if C = 3 and I incr C to 4, I want to cls only once, even if C is still 4. If I say If C=4 then cls it will cls every cycle (490 times a second) because C is still 4.

BASCOM-AVR : Do something when var changes : REPLY

$
0
0
Please post the code (short as possible but that show the issue) For reading more than one one pin from port I use pinmasks [code:1:2da210c96b] Const Sw_mask = &B00011110 'checked will be bits/pins 1,2,3 and 4 Sw_state = Pinb And Sw_mask If Sw_state <> Sw_mask Then End If [/code:1:2da210c96b] To understand how switches can be handle look at this short one button example. [code:1:2da210c96b]' This code toggle Led_1.after short push on Switch and toggle Led_2 when Switch is pus and hold for long $regfile = "m16def.dat" $crystal = 8000000 $hwstack = 32 $swstack = 16 $framesize = 64 Config Porta.6 = Output : Led_1 Alias Porta.6 Config Porta.7 = Output : Led_2 Alias Porta.7 Config Porta.0 = Input : Set Porta.0 : Switch Alias Pina.0 Dim Sw_cnt As Byte , Lock As Byte Config Timer2 = Timer , Prescale = 1024 , Compare = Disconnect , Clear_timer = 1 COMPARE2 = 77 '10ms @8MHz/1024 Do If Tifr.ocf2 = 1 Then 'the 10ms is past, this flag set the Timer Tifr.ocf2 = 1 'clearing the flags is done by writing ones NOT ZEROS! If Switch = 0 Then 'if button is pressed If Lock = 0 Then 'and lock is not triggered If Sw_cnt < 50 Then 'we increase sw_counter if long_push value not reached Incr Sw_cnt 'increaseing counter Else 'but if we hold button long.. Lock = 1 'lock increasing the counter Toggle Led_2 '->and change state of LED_2 because it is long_push End If End If Else '..if button is released If Lock = 0 Then ' and previous,it was not a long push activity If Sw_cnt > 3 Then Toggle Led_1 'check if button was pressed atleast 3 periods (3x10ms) End If '->toggle LED_1 because it was short click Lock = 0 : Sw_cnt = 0 'clear lock and counter End If End If Loop End[/code:1:2da210c96b]

BASCOM-AVR Old versions : Need help tp get dirrection for frequency sweeper pls. : NEWTOPIC

$
0
0
Hi! I need some help to do this project: I need to make a frequency sweeper with 5V square wave output (Duty cycle 50%, effective frequency range from over 10kHz (max 50kHz) to 50Hz) . Can I do this with the tone function or should I use a timer or what would be the best solution? I would use some Attiny2313 or 85 maybe I think I have on stock. Some example code would be great for start. Thanks in advice. My best regards.

BASCOM-AVR : Do something when var changes : REPLY

$
0
0
[quote:4b8f72ac95="EDC"] [/quote:4b8f72ac95] I will try if I can use your button/switch thing, it will definitely help me for some cases but it is hard to see it from my code because it is not working :roll: [code:1:4b8f72ac95] Enable Interrupts Config Timer0 = Timer , Prescale = 64 On Timer0 Casovnik : Enable Timer0 Config Debounce = 20 Count = 1 wait 5 cls B=0 C=1 Do Debounce tipkaparametri , 0 , meni , Sub If 0 < Ischarwaiting() Then Inputbin Array(count) , 1 Timeout = 100 If Count < 17 Then Incr Count Else [/code:1:4b8f72ac95] If you remember you helped me with that transmission. [code:1:4b8f72ac95] 'Meni za prikaz stanja vode v rezervarju' If C = 1 then Locate 1 , 1 : Lcd "Meritve vode: ";B; Locate 1 , 20 : Lcd ;A; Locate 2 , 2 : Lcd "Globina: " ; SP3 ;" cm " Locate 3 , 2 : Lcd "Volumen: " ; Fusing(CUB1 , "#.###") ;" m"; Chr(4) ;" " Locate 4 , 2 : Lcd "Nivo v %: " ; Fusing(procenti , "#.#") ;" % " Locate 4 , 20 : Lcd ;C; End if 'Osnovni meni' If C = 2 then Locate 1 , 1 : Lcd "*** STANJE VODE ***" Locate 2 , 1 : Lcd "Breznica pod" Locate 3 , 1 : Lcd " Lubnikom 15 " Locate 4 , 8 : Lcd ;Fusing(procenti , "#.#") ;" %" Locate 4 , 20 : Lcd ;C; If procenti > 99 and pretokaktiven <> 0 then Locate 4 , 4 : Lcd ;Chr(7);;Chr(7);;Chr(7); end if If procenti =< 99 and procenti > 98 and pretokaktiven <> 0 then Locate 4 , 5 : Lcd ;Chr(7);;Chr(7); end if If procenti =< 98 and procenti => 97 and pretokaktiven <> 0 then Locate 4 , 6 : Lcd ;Chr(7); end if if pretokaktiven = 0 then Locate 4 , 4 : Lcd ;Chr(5);;Chr(5);;Chr(5); end if end if [/code:1:4b8f72ac95] So when I press the button I increase C, If C=1 then I have the first menu and if C=2 then it shows second menu. When I press button, menu 1 will appear for example but if I press it again menu 2 will have some letters remaining from menu 1 because I don't have cls. If I put cls at the beginning of every menu, then menu will be blinking. What I want to do is that if I change the menu, I would cls so I don't have anything from previous menu, but then I do not cls unless I change the menu again. The other part is that I have some signs for inputs. If I have some inputs active I have some arrows on my LCD (different for every input), but sometimes no input is active then I want to cls to remove all arrows. But only once not every time when atmega will read that pinc.0=0 because I would get blinking all the time again. [code:1:4b8f72ac95] Else Cls Lcd "";Chr(1);"akam povezavo..." End If Count = 1 End If End If Waitms 1 'this will set array pointer to start if not whole array arrive on time If Timeout > 0 Then Decr Timeout Else Count = 1 End If Loop Casovnik: 'Nastavitev 1 sekunde za Incr A intervala' Cas1 = Cas1 + 1 If Cas1 >= 490 Then 'Nastavitev zakasnitve, št. ciklov po 64, ker PS=64' Cas1= 0 End If If Cas1 = 1 then Incr A If A => 10 then A=0 End if 'Nastavitev cls' If C = 1 OR C = 2 OR C = 3 OR C = 4 then Cas4 = Cas4 + 1 If Cas4 >= 201 Then 'Nastavitev zakasnitve, št. ciklov po 64, ker PS=64' Cas4= 0 End If end if If Cas4 = 200 then D = C If D <> C and Cas4 = 199 then cls Return Meni: incr C if C => 5 then C = 1 Return [/code:1:4b8f72ac95] This is just the end with timers, that I used so far. For example every second I increase A from 1 to 10. Is it possible to say if pinc.0=0 then A=1, but continues to count up to 10 even if pinc.0 stays = 0. Because if I write If pinc.0 = 0 then A=1, A will remain 1 and it will not increase until pinc.0 <> 0. Many thanks for your help already!

BASCOM-AVR : GETRC with xmega128d4 : REPLY

$
0
0
Yes, right. Porta.5 = Output to Charge the capacitor then wait 10ms, or better 100ms then switch the port as Input Porta.5 = Input, and turn the avr pull-down on. Then test how long it takes to discharge the capacitor.

BASCOM-AVR : Do something when var changes : REPLY

$
0
0
If I understand the code enough program refresh LCD only if new data arrive and You want to view diferrent menu pages/values from that one transmission. You also want to update some view with timer, and it would be nice to update LDC with button :D This can be easy done. You must independ showing data on lcd from Ischarwaiting() I add variable Refresh. This variable can be set by incommind data, by presing the button or timer tick :D So if Refresh = 1 LCD wil be updated depending on variable C value :D Look at this pseudo code [code:1:cc09cb4f58]Dim Refresh As Byte Do If 0 < Ischarwaiting() Then If Data Is Valid Then Refresh = 1 End If Debounce Switch , 0 , Switch_sub , Sub 'button If Refresh = 1 Then 'independent from Ischarwaiting Refresh = 0 'show only once per "Refresh = 1" 'switch also can set this flag to 1 Cls 'clear then screen only once Select Case Menu Case 1 Case 2 Case 3 End Select End If Loop End Switch_sub: Incr Menu : If Menu > 3 Then Menu = 1 Refresh = 1 'switch also can trig the refresh ;) Return Timer_tick: Incr Ticker If Ticker > Period Then Ticker = 0 : Refresh = 1 End If Return [/code:1:cc09cb4f58] ..and now its timefor another tip :D This is not nice solution [code:1:cc09cb4f58]If C = 1 Or C = 2 Or C = 3 Or C = 4 Then 'all conditions are for the same variable End If[/code:1:cc09cb4f58] Better would be: [code:1:cc09cb4f58]Select Case C Case 1 To 4 : 'do something End Select[/code:1:cc09cb4f58] Your code slightly modified, but not tested, attached. This is for show the idea. Have a nice day ;)

BASCOM-AVR : Do something when var changes : REPLY

$
0
0
[quote:07c98a99f7="EDC"] [/quote:07c98a99f7] Well Bardzo dziękuję! :D I have found "case" thing few days ago because I was looking for this solution, but haven't put it in yet because I was not 100% sure in it and I had other problems to solve. But code is much bigger then I thought before I started this project and I am always adding something and deleting something else, that is why code is a mess. And also I did something the ways I knew how at that time but then I figured there is a command for it and can be done with much less effort :D As a first project it will do even if it is a little messy :D But I am getting addicted to this. Thank you very much again! :D

Share your working BASCOM-AVR code here : Font File Maker 2 : NEWTOPIC

$
0
0
Hello. Just yesterday, when I program some device with OLED, I was think that it will be nice to use TT proportional fonts. uC in this project is small so it would be also nice when font file will be small too :D So I was start thinking about Bascom TT fonts and do some test. This tests brings me new idea that by adding value >0 in place described in Help under topic "Font Editor" fonts can be translated into TT type :P You can check with your favoured font by editing it if this work for you. I dont have time for more tests but I add new function into my Font Maker. Program I post here, but note that on my site I can quick replace it with new version if I found a bug. Look how view on the OLED differ by simply add value 2 in magic place :D Upperline is the new method and old metod is in lowerline. Have a nice day and let me know how it works for You :D

Share your working BASCOM-AVR code here : Font File Maker 2 : REPLY

$
0
0
Looks very good!! Have fun Ben Zijlstra

Share your working BASCOM-AVR code here : Font File Maker 2 : REPLY

$
0
0
Thanks for sharing and the update. :D Yes without doubt, a TT font looks way better in most cases.

BASCOM-AVR : Display 32-bit number on lcd : NEWTOPIC

$
0
0
Hello I want do display a 32-bit number on LCD. Number is unsigned and declared as DWORD. Will STR(X) work correctly with DWORD variables. Maybe other solutions? Regards JP [b:8a65e4b627][color=red:8a65e4b627](BASCOM-AVR version : 2.0.7.3 , Latest : 2.0.7.8 )[/b:8a65e4b627][/color:8a65e4b627]

BASCOM-AVR : Display 32-bit number on lcd : REPLY

BASCOM-AVR : Can somebody help me to translate from asm to bascom this co : NEWTOPIC

$
0
0
Hi! I have a long time ago written software in a AT89C2051, I got out the bin file and disassembled it with the "D52 Microcontroller Disassembler" to asm but I'm not an asm guru but I wish my code transfer to Attiny2313 uC. Thank's in advice for help. Hele is the ASM code: [code:1:44d3131b7a] ; ; D52 V3.4.1 8052 Disassembly of oldies.bin ; 2017/04/06 21:56 ; org 0 ; mov tmod,#20h mov th1,#0f6h setb tr1 mov scon,#40h orl pcon,#80h mov r7,#9 X0010: acall X0016 djnz r7,X0010 X0014: sjmp X0014 ; X0016: mov sbuf,#40h X0019: jnb ti,X0019 clr ti nop ; org 20h ; mov sbuf,#57h X0023: jnb ti,X0023 clr ti nop ; org 2ah ; mov sbuf,#73h X002d: jnb ti,X002d clr ti nop ; org 34h ; mov sbuf,#0 X0037: jnb ti,X0037 clr ti nop ; org 3eh ; mov sbuf,#0f6h X0041: jnb ti,X0041 clr ti nop ; org 48h ; mov r1,#0 mov r2,#0 mov r3,#1 X004e: nop djnz r1,X004e djnz r2,X004e djnz r3,X004e mov r1,#0 mov r2,#0 mov r3,#1 X005b: nop djnz r1,X005b djnz r2,X005b djnz r3,X005b ret ; end ; [/code:1:44d3131b7a] [b:44d3131b7a][color=red:44d3131b7a](BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.8 )[/b:44d3131b7a][/color:44d3131b7a]
Viewing all 20696 articles
Browse latest View live


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