you better not change the dat files.
i see the USB is missing. Tomi will add them.
you can simply do this : PR_PR.6=1
the usb module itself is disabled by default.
↧
BASCOM-AVR : USB shutdown PRGEN XMEGA : REPLY
↧
BASCOM-AVR : USB shutdown PRGEN XMEGA : REPLY
Thanks Mark,
It didn't look like patching the DAT file would help, using the PR_PR will work for now. We did get a 0.5mA reduction by turning off all modules, was hoping for more current reduction, which modules are on by default ?
↧
↧
BASCOM-AVR : Print lower case bug !!! : REPLY
I think at this stage I would be sending just one repeated character, while looking at the signal line with a CRO to see what pattern is actually being sent. But I must admit that its odd that it seems to work ok in upper case but not lower. The difference is only that bit 5 is set to send lower case.
Maybe a look also with some terminal program like Realterm, which allows to display the Hex code of what is received would show up what is wrong. The characters you quote seem to indicate that bit 7 is being set, but that may just be a terminal trying to interpret garbage.
↧
BASCOM-ARDUINO : Help _ simple examble for RX UART data : REPLY
[quote:ec83774ce7="bzijlstra"]What I don't understand is how you Dim value as byte and later on check if value = "AAA" A byte is a value of 0 - 255. What you need is a string to hold the characters.
You first have to grab all incoming characters in a string and check the string for "AAA"
In the weatherstation that is done. Inkey to check for a character, add it to a string and with instr a check is done if some keywords are in the string.
You are nearly there...
Have fun
Ben Zijlstra[/quote:ec83774ce7]
[img] http://www14.0zz0.com/2016/02/06/04/483675159.jpg[/img]
atmega8 _ 1
[code:1:ec83774ce7]
$regfile = "m8def.dat"
$crystal = 4000000
'------------------------
Dim Value As String*6
Config Portb.0 = Input
Config Portb.1 = Output
Portb.1 = 0
Portb.0 = 1
'------------------------
Open "comd.6:9600,8,n,1" For Output As #6
Open "comd.7:9600,8,n,1" For Input As #5
'------------------------
Do
Value = Inkey(#5)
If Value > 0 Then
If Value = "AA" Then Toggle Portb.1
End If
'----------------
'recived value
If Pinb.0 = 0 Then
Print #6 , "AA"
Waitms 100
End If
Loop
[/code:1:ec83774ce7]
atmega8 _2
[code:1:ec83774ce7]
$regfile = "m8def.dat"
$crystal = 4000000
'------------------------
'Ucsrb = 0
Dim Value As String*6
Config Portb.0 = Input
Config Portb.1 = Output
Portb.1 = 0
Portb.0 = 1
'------------------------
Open "comd.6:9600,8,n,1" For Output As #5
Open "comd.7:9600,8,n,1" For Input As #6
'------------------------
Do
Value = Inkey(#6)
If Value > 0 Then
If Value = "AA" Then Toggle Portb.1
End If
'----------------
'recived value
If Pinb.0 = 0 Then
Print #5 , "AA"
Waitms 100
End If
Loop
[/code:1:ec83774ce7]
the circuit and code NOT WORKING ???
i hope to update this code to working
↧
BASCOM-ARDUINO : Help _ simple examble for RX UART data : REPLY
- I'm sorry but I don't understand why you don't use PD.O and PD1 the hard serial pin for your communication.? on your schematic they are free...
- sometimes serial communications are difficult to adjust because following the sentence you print you have CR+LF
see the help :
[quote:90b4366969]You can use a semicolon (;) to print multiple variables or constants after each other.
When you end a line with a semicolon, no linefeed and carriage return will be added.
[/quote:90b4366969]
so [quote:90b4366969]If Value = "AA" Then Toggle Portb.1[/quote:90b4366969] while never right be cause, in fact you send AA+CR+LF
- split you program in small parts, then try them, use simulator, it works well
JP :wink:
↧
↧
BASCOM-ARDUINO : Help _ simple examble for RX UART data : REPLY
[quote:680538cf49="Duval JP"]- I'm sorry but I don't understand why you don't use PD.O and PD1 the hard serial pin for your communication.? on your schematic they are free...
- sometimes serial communications are difficult to adjust because following the sentence you print you have CR+LF
see the help :
[quote:680538cf49]You can use a semicolon ( ; ) to print multiple variables or constants after each other.
When you end a line with a semicolon, no linefeed and carriage return will be added.
[/quote:680538cf49]
so [quote:680538cf49]If Value = "AA" Then Toggle Portb.1[/quote:680538cf49] while never right be cause, in fact you send AA+CR+LF
- split you program in small parts, then try them, use simulator, it works well
JP :wink:[/quote:680538cf49]
ok i already use PD0 PD1 in another project _ this circuit for explanation simply what I want
i cant understand [ in fact you send AA+CR+LF ]
??
↧
BASCOM-ARDUINO : Help _ simple examble for RX UART data : REPLY
From the factory the ATmega8 comes with its CKSEL fuses programmed for 1 Mhz.
What about your fusebit settings?
You got an atmega8 and a LED. Is it possible to write a small program to just blink the LED at an interval of 1 second?
And if you Print "AA" you are sending AA+CR+LF
If you just want to send "AA" you do a Print "AA";
Ben Zijlstra
↧
BASCOM-ARDUINO : Help _ simple examble for RX UART data : REPLY
[quote:10a07c46c2="bzijlstra"]From the factory the ATmega8 comes with its CKSEL fuses programmed for 1 Mhz.
What about your fusebit settings?
You got an atmega8 and a LED. Is it possible to write a small program to just blink the LED at an interval of 1 second?
And if you Print "AA" you are sending AA+CR+LF
If you just want to send "AA" you do a Print "AA";
Ben Zijlstra[/quote:10a07c46c2]
about fuse
-Did not try practically Simulations only
Print "AA"; ok but i need to print in software to specific pin like [ Print #6 , "AA" ;] [#6] // output pin define it soft
[Open "comd.6:9600,8,n,1" For Output As #6]
whai is CR+LF mean ??how can i neglect it software[/quote]
↧
BASCOM-ARDUINO : Help _ simple examble for RX UART data : REPLY
From my school : 46 years old !
ASCII code 0 à 27 for serial use THIS CHARACTER ARE NOT DISPLAYED !
Note 0, 10 and 13 and 27
Code ASCII
0 Null
is not nothing ! you can send a chr(0) 'null
1 SOH
start of head
2 STX
start of text
3 ETX
end of tex
4 EOT
end of transmission
5 ENQ Who are you ?
6 ACK
Acknoledge
7 BEL
ring
8 BS
back slash 1 lettre en arrière
9 HT 1lettre en avant
10 LF
Line feed (avance d'une ligne)
11 VT
Vertical Tabulation
12 FF
Start new page 'début prochaine page
13 CR
(Carriage Return) retour chariot -à la ligne
17 DC1 XON
18 DC2 Contrôle dispo 2
19 DC3 XOFF
20 DC4 Contrôle dispo 4
21 NAK Bad reception Mal reçu
22 SYN
23 ETB Reçu? J'attends
24 CAN Annulé
25 EM
26 SUB End of file 'Fin de fichier
27 ESC
:wink: JP
↧
↧
BASCOM-ARDUINO : Help _ simple examble for RX UART data : REPLY
Dim value as string * 6
Value = inkey(#6)
Value gets only one character.
So it will never get "AA"
If you realy studied the weatherstation code you will notice that I use a buffer and with an INSTR check if the keywords pass by.
There is nothing wrong with your hardware.what is missing is a good crystal to get a correct baudrate.
At the start you mentioned things are working on single characters, so this must be the error.
Have fun
Ben Zijlstra
↧
Share your working BASCOM-AVR code here : Moving average for INTEGER and SINGLE data streams : REPLY
Hi Per,
I was looking for an implementation of a Moving Average. As Simple Moving Average [url]https://en.wikipedia.org/wiki/Moving_average[/url]
That is SMA(last n samples) = (last n samples) / n.
The title of your contribution suggests (to me) that your filter "Running Average" does the Simple Moving Average, but....
[i:c9b90a8915]Function Runavg(byval Newval As Integer , Sum As Long , Byval Factor As Byte ) As Integer
'Running Average for any INTEGER variable
'NEWVAL is the new value to add to the statistics (preserved)
'SUM is an accumulator dedicated to a specific sensor channel (global variable)
'FACTOR is the average factor. It MUST be in the range 0 to 8, where 0 mean CLEAR ALL, and 8 mean 256 samples
'RUNAVG is a return variable (the arithmehic mean of all values in Accum, divided by FACTOR)
Local Ltmp As Long 'The same as "L" but as a LONGWORD
'Reset to Newval (Make average equal to Newval)
If Factor = 0 Then
Sum = Newval
Shift Sum , Left , Factor
Runavg = Newval
Exit Function
Else
'Moving average
Ltmp = Sum
Shift Ltmp , Right , Factor , Signed 'compute data average from accumulated values
Sum = Sum - Ltmp 'subtract the old average
Sum = Sum + Newval 'add the new value
Runavg = Ltmp
End If
End Function[/i:c9b90a8915]
I did do [u:c9b90a8915]by hand[/u:c9b90a8915] your function, using the [i:c9b90a8915]Else[/i:c9b90a8915] branch and with [i:c9b90a8915]FACTOR[/i:c9b90a8915] = 2 (divide by 4), and start with everything = 0, and then all [i:c9b90a8915]Newval[/i:c9b90a8915] = 1.
Results for[i:c9b90a8915] Runavg[/i:c9b90a8915] for 7 steps: 0, 1/4, 7/16, 47/64, 205/256, 871/1024, 3037/4096
Or in decimal: 0 .25 .4375 .734 .800 .85 .888
Your filter looks like a first order low pass filter.
It does a nice smoothening, but... IMHO it does not have (Simple) Moving Average filter behaviour.
That should have given 0 .25 .5 .75 1 1 1
↧
BASCOM-ARDUINO : Help _ simple examble for RX UART data : REPLY
Hi Duval,
Well, many of us in this Forum have more than 50 years.... And we have worked sometimes witm modens and serial rs232 comunication. I have worked with Apple ][ videotext in ASM , and have pained with the Hardware 1200 /75 bps communications and Videotext protocol here at Brazil.
I see all values you have posted for the ascii code, and think .... today most schools don't teach this anymore !
What you ( and many of us ) think that is obvius, maybe is not so obvius because the learning today is focused in others comunication types, like Rs422 and others.
Seeing this topic leaves me to think that we are like dinossaurs in the 20 century..... All our knowledge is useless to the new generation..... At least this is what the "new generation engineers" thinks....
If we tell something like 7 bits / even parity / 2 stop bits many people will think that we are crazy !
This topic is strange because only the old peoples understand that we cant have an "55AA" using the normal commands. We need to read two bytes and join the values !
Making the "new generation" people understand this is not an easy task !
Paulo
↧
BASCOM-AVR : Howto get an AVR calculated array transferred to Bascom DATA : NEWTOPIC
Here I have several calculated tables, like this log table:
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&p=69879#69879
[code:1:25a05b5178]Dim Adc_ln(1024) As Word 'Table Elements for Logarithm of Voltage[/code:1:25a05b5178]
Adc_ln() is now calculated by AVR and stored in RAM. That is OK for testing, but at some point it is time to freeze and have it as DATA in the program.
My best idea is to print the array values to a serial terminal and then save that as file, and then somehow merge that with the Bascom program.
What I do not know in what format to export/import the data.
Should it be text as I read it under normal DATA statements?
Or should it be binary?
It may be simple, but this method looks complicated to me.
I would like to see an example of the procedure. My table is an array is a 1024 words.
My best hope is... that there is some command feature in Bascom that does this for me, without the hassle of importing/exporting setting formats.
Is there a "create_RAM to DATA(-file/program)" command?
Or could that be made for a future version?
[b:25a05b5178][color=red:25a05b5178](BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 )[/b:25a05b5178][/color:25a05b5178]
↧
↧
BASCOM-AVR : Howto get an AVR calculated array transferred to Bascom DATA : REPLY
You can save it to SD-Card with Write function - http://members.aon.at/voegel/ - or to SPI EEPROM 25xx, I2C EEPROM 24xx. [/url]
↧
BASCOM-AVR : Howto get an AVR calculated array transferred to Bascom DATA : REPLY
This is how I do it:
AVR prints the data to a serial port of a PC. AVR adds comma's between the values and adds a CR/LF at a convenient location (20 datapoints per line is what I prefer)
PC stores the data in a log-file. Br@y terminal is my favorite.
When done, you'll have a so called csv file (comma separated file) on the PC. Now open that file with your favorite spreadsheet. Add a column at the very left of the cells and put the word "data" in there. Since you have the data in a spreadsheet, you can perform some offset and gain tricks, filtering ... whatever you find necessary.
Now save the spreadsheet as .csv once more. Open it then with a text editor. Programmers Notepad is what I use. Now copy all text to your Bascom program. The nasty comma after Data I delete by hand.
Quite some work, I know. But it works.
And I am all ears for a simpler way :)
Nard
↧
BASCOM-ARDUINO : TFT 5inches, ssd1963 and Mega 2560 : REPLY
How is the retrieval of values (X,Y) of the Touch screen SSD1963 ?
↧
BASCOM-AVR : Howto get an AVR calculated array transferred to Bascom DATA : REPLY
Maybe something like
[code:1:58e2998f2d]
Dim I As Byte
Dim J As Byte
Dim K As Word
Dim Adc_ln(1024) As Word
K = 0
for I = 0 to 255
Print "data ";
For J = 1 To 15
K = K + 1
Print Adc_ln(k) ; ", ";
Next J
K = K + 1
Print Adc_ln(k)
next I
[/code:1:58e2998f2d]
↧
↧
BASCOM-ARDUINO : Help _ simple examble for RX UART data : REPLY
thanks for your post Paulo,
É o velho panelas que fazemos os melhores doces :lol: I hope Bing translator work well !
Jean-Pierre
↧
BASCOM-AVR : Howto get an AVR calculated array transferred to Bascom DATA : REPLY
Hi guys thanks for your suggestions.
@Prshilov: I do not have SD-card. I am using STK200+M1284+CharLCD+Serial
@Plons: Thanks for confirming 'My best idea'. I feel encouraged to learn the procedure.
@laborrate: Thanks a lot for the basic example!
By the way: I think this will also learn me how to split up up a large program in separate components. I feel encouraged to become familiar with .include and .inc
So far I allways had 1 long file.bas. When that spreads over more pages it becomes harder to keep the overview.
My problem is that in User area I often 'accidentally' change the files, even after they were working well...
I feel the need to have some WriteProtect for the files that I would like to keep unchanged. Just saving them in a separate User directory ('FinishedProgram') does not work for me: if I open them in Editor even the slightest touch is a change.
May be I should simply set the WriteProtect check...?
Or save them somewhere in ProgramFiles/BASCOM...?
How do you guys handle that?
↧
BASCOM-AVR : Howto get an AVR calculated array transferred to Bascom DATA : REPLY
If you check the source of the Weatherstation you will see that HKipnik used directories for TFT-drivers, fonts, data, AVR-Dos and pictures.
So on a next project I would like to make with the same hardware, I only have to copy the subdirectories in a new folder/directory and start the new project. I haven't got to touch the base routines.
Perhaps add some fonts and pictures.
I could use however an .inc file for the DIMs that are specific for this project but leve this .inc file in the main directory.
There are more solutions like this:
Project within Bascom-AVR itself
SUSI from Six1
And Framework from Thomas Riessen
Have fun
Ben Zijlstra
↧