View previous topic :: View next topic |
Author |
Message |
GIANNHS
Joined: 25 Mar 2016 Posts: 16 Location: Greece
|
Posted: Wed Apr 20, 2016 4:13 pm Post subject: |
|
|
Thanks Paulo the attiny45 is fit for this work ???
How can I tell from the second counter attiny45 crossing to the price before gauge and blah blah |
|
Back to top |
|
|
GIANNHS
Joined: 25 Mar 2016 Posts: 16 Location: Greece
|
Posted: Wed Apr 20, 2016 7:27 pm Post subject: |
|
|
built it following but unfortunately not WORKING
$regfile = \"attiny45.dat\"
$crystal = 1000000
$hwstack = 16
$swstack = 16
$framesize = 8
Dim Adc_value As Word
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer0 = Pwm , Prescale = 64
Tccr0a = Bits(com0a1 , Wgm00 , Wgm01 )
Config Timer1 = Pwm , Prescale = 64
Tccr1 = Bits(com1a1 . Wgm00 , Wgm01 )
Config Pinb.4 = Input
Config Pinb.3 = Input
Config Portb.0 = Output
Config Portb.1 = Output
\'--------------------------------------------------------------------------
Do
Adc_value = Getadc(2)
Ocr0a = Adc_value / 10
Adc_value = Getadc(3)
Ocr1a = Adc_value / 10
Loop
End |
|
Back to top |
|
|
aphawk
Joined: 23 Jan 2010 Posts: 168 Location: Brazil
|
Posted: Wed Apr 20, 2016 8:41 pm Post subject: |
|
|
You must make the modifications I told you in my last post....
You must read the second Pot with ADC, scale the value to the time you need.
Then you read the first PWM output, when it has High level, you will generate the pulse : the High level time will be that you have made the scale, and the Low level will be the rest of time to give the total time you want.
Paulo |
|
Back to top |
|
|
GIANNHS
Joined: 25 Mar 2016 Posts: 16 Location: Greece
|
Posted: Wed Apr 20, 2016 9:43 pm Post subject: |
|
|
a better
$regfile = \\\"attiny45.dat\\\"
$crystal = 1000000
$hwstack = 16
$swstack = 16
$framesize = 8
Dim Adc_value As Word
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer0 = Pwm , Prescale = 64
Tccr0a = Bits(com0a1 , Wgm00 , Wgm01 )
Config Timer1 = Pwm , Prescale = 64
Tccr1 = Bits(com1a0 , Cs00 , Cs01 , Cs01 , Cs01 )
Config Pinb.4 = Input
Config Pinb.3 = Input
Config Portb.0 = Output
Config Portb.1 = Output
\\\'--------------------------------------------------------------------------
Do
Adc_value = Getadc(2) \\\'ρυθμιζει σε ποια port η pin (ADC2 PB4) εχουμε την adc
Ocr0a = Adc_value / 10 \\\'ρυθμιζει την διαρκεια του παλμου hagh στο pwm
Adc_value = Getadc(3)
Ocr1a = Adc_value / 10
Loop
End |
|
Back to top |
|
|
GIANNHS
Joined: 25 Mar 2016 Posts: 16 Location: Greece
|
Posted: Thu Apr 21, 2016 6:08 pm Post subject: |
|
|
aphawk
1) Which command reads the first outing PB0 ??????
Give me an example.
2) HOW DIAVAZO THE SECOND pot to make CHANGING DELAY
Give me an example. |
|
Back to top |
|
|
aphawk
Joined: 23 Jan 2010 Posts: 168 Location: Brazil
|
Posted: Fri Apr 22, 2016 4:03 pm Post subject: |
|
|
I made one example with Attiny13.
First, to my circuit work, you must connect together the pins 5 and 7.
The code is :
Code: |
$regfile = "attiny13.dat"
$crystal = 9600000
$hwstack = 16
$swstack = 16
$framesize = 16
Dim Adc_value As Word
Dim Scale As Word
Dim Test As Bit
'please connect the pins 5 and 7 together !
Config Portb.2 = Input
Config Portb.1 = Output
Config Portb.0 = Output
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer0 = Pwm , Prescale = 64 , Compare A Pwm = Clear Up , Compare B Pwm = Disconnect
'--------------------------------------------------------------------------
Do
' first, read the new pot
' and use it to have a value between 10 and 45
Scale = Getadc(2)
Scale = Scale * 35
Scale = Scale / 1023
Scale = Scale + 10 'ok scaling was made
'Now read the first pot and fit the value between 0 and 255
Adc_value = Getadc(3) / 4
Pwm0a = Low(adc_value)
'now make the second output low
Portb.1 = 0
'wait some minimal time
nop
nop
nop
'now we will wait the first output goes to high
Go_again:
Test = Pinb.2
If Pinb.2 = 0 Then Goto Go_again
'the first output has high level
'now we will wait the time scaled from the second pot
Waitus Scale
' and put in the second output in high level
Portb.1 = 1
'and wait the total time to 500usec, but
'compensating the first time in level high !
Scale = 500 - Scale
Waitus Scale
Portb.1 = 0
' ok, all was done
Loop
End
|
See the attached file for the Bascom program and the circuit used.
You don't give enought information about the second output, I only make the delay you need as a example of code.
To make a better program, you must inform the right temporizations, like the frequency of the PWM you need,
( note that whe have few choices for the Prescaler that define the frequency ), and the way that the second output must work.
Now, you can fit the code to your exactly requeriments ok ?
Paulo |
|
Back to top |
|
|
GIANNHS
Joined: 25 Mar 2016 Posts: 16 Location: Greece
|
Posted: Mon Apr 25, 2016 6:56 pm Post subject: |
|
|
οκ thank you very much paulo
ok hour for study
|
|
Back to top |
|
|
GIANNHS
Joined: 25 Mar 2016 Posts: 16 Location: Greece
|
Posted: Wed Apr 27, 2016 12:51 pm Post subject: |
|
|
can you explain the three phase of (scale)
Scale =Scale * 35 \\\'???
Scale = Scale / 1023 \\\'????
Scale = Scale + 10 \\\'???? |
|
Back to top |
|
|
GIANNHS
Joined: 25 Mar 2016 Posts: 16 Location: Greece
|
Posted: Thu May 05, 2016 5:48 pm Post subject: |
|
|
How can I change the delay from 10 to 45 for example from 10 t0 200 |
|
Back to top |
|
|
aphawk
Joined: 23 Jan 2010 Posts: 168 Location: Brazil
|
Posted: Thu May 05, 2016 6:49 pm Post subject: |
|
|
GIANNHS wrote: | can you explain the three phase of (scale)
Scale =Scale * 35 \\\'???
Scale = Scale / 1023 \\\'????
Scale = Scale + 10 \\\'???? |
This is to transform the ADC output to an number between 10 ( adc read=0) and 45 ( adc read =1023 ) that was you ask for !
Paulo |
|
Back to top |
|
|
aphawk
Joined: 23 Jan 2010 Posts: 168 Location: Brazil
|
Posted: Thu May 05, 2016 6:53 pm Post subject: |
|
|
GIANNHS wrote: | How can I change the delay from 10 to 45 for example from 10 t0 200 |
As my last answer :
Scale =Scale * 20
Scale = Scale / 102
Scale = Scale +10
You will have result from 10 to 200 !
Paulo |
|
Back to top |
|
|
|