bascom arduino - presepio

Sezione dedicata al sistema di sviluppo BASCOM-AVR per i micro AVR
At90s, Attiny, Atmega e Xmega

bascom arduino - presepio

Postby massibal » 05 Sep 2012, 11:25

salve a tutti...e grazie per le risposte!
rispondo :
Hai un condensatore di disaccoppiamento vicino al display? NO
- Sei su breadboard? SI
- Hai un oscilloscopio per fare delle verifiche? NO
- L'alimentazione è sufficiente, l'alimentatore è ben dimensionato? SI
- Puoi pubblicare lo schema del circuito? NO

sotto riporto però il file del programmino.... chiedo scusa in anticipo per eventuali castronerie .. !

grazie e buon week end

papà Massi



' **********************************************************************
' * File: presepemax_2012.bas - Rel. x.n del 04.05.12 by Max B:
' * Scheda: ARDUINO UNO con Bascom AVR
' * PROVE Funz.con sheda ARDUINO e BascomAVR
' **********************************************************************
'
'****************** Direttive del compilatore **************************
'
$regfile = "m328pdef.dat"
$crystal = 16000000
$baud = 19200
Config Clockdiv = 2

Config Pind.3 = Input ' echo
Config Portd.2 = Output ' trigger
Config Portb = Output
Config Portd.7 = Output
Config Portd.4 = Output

'$sim
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
Config Timer0 = Pwm , Prescale = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
Config Timer2 = Pwm , Prescale = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
Config Debounce = 50
'Config Adc = Single , Prescaler = Auto , Reference = Internal

'****************** Dichiarazione delle costanti ***********************
'
Const Mas = " PRESEPE 2012 "
'
'****************** Dichiarazione delle variabili **********************
'
Dim N As Byte , I As Byte , A As Byte
Dim Var As String * 1
Dim Su As Byte , Giu As Byte
Dim Tempo As Word
Dim Dist As Word
'
'************************* Programma main ******************************
'
Disable Interrupts 'Disabilita interrupt
Cls : Cursor Off 'Inizializza LCD
Lcd Mas
Print Mas
Waitms 2500
Cls
Lcd "Test comandi ON"
Print "Test comandi ON"
For N = 0 To 7
Portb = 2 ^ N
Waitms 20
Next
Set Portd.7
Waitms 50
Reset Portd.7
Waitms 50
Set Portd.4
Waitms 50
Reset Portd.4
Waitms 50
Reset Portb.0
Pwm2a = 0
Waitms 50
Pwm2a = 255
Cls
Lcd "Test comandi OFF"
Print "Test comandi OFF"
Waitms 200

Avvio:
Cls
Print "Avvia il Presepio "
Upperline
Lcd " Avvia il "
Lowerline
Lcd " presepio "
Via:
Waitms 20
' Portd.2 = 1

Pulseout Portd , 2 , 400
'Portd.2 = 0

Pulsein Tempo , Pind , 3 , 1
Tempo = Tempo * 10
Dist = Tempo / 29
If Dist < 4 Then
Gosub Programma
Elseif Dist >= 4 Then
Goto Via
Waitms 10
Cls
End If
Programma:
Print "PROGRAMMA_CARLO_ON"
Cls
Lcd "PROGRAM_CARLO_ON"
For A = 1 To 16
Shiftlcd Right
Waitms 300
Next
For A = 1 To 16
Shiftlcd Left
Waitms 300
Next

For Su = 255 To 0 Step -1
Pwm2a = Su 'accende gradatamente LUCI_GIORNO
If Su = 150 Then Set Portb.2 ' fontana UP
If Su = 120 Then Set Portd.7 ' pastori (treno)-nonna UP
If Su = 100 Then Set Portb.5 ' panni stesi - UP
Waitms 20
Next
Waitms 1000
For Giu = 0 To 255
Pwm2a = Giu 'spegne gradatamente LUCI_GIORNO
If Giu = 50 Then Reset Portd.7 ' pastori (treno)-nonna DOWN
If Giu = 80 Then Reset Portb.5 'panni stesi - DOWN
If Giu = 120 Then Reset Portb.2 'fontana DOWN
If Giu = 150 Then Set Portb.0 'fuoco UP
Waitms 20
Next
Portb.1 = 1 'stelle UP
Waitms 500
Lowerline : Lcd "STELLE ACCESE"
Set Portb.4 'luci case UP
Waitms 500
Lowerline : Lcd "LUCI CASE ACCESE"
Set Portd.4 ' luce notte UP
Waitms 500
Lowerline : Lcd "LUCE NOTTE ACCESE"
Reset Portb.0 'fuoco DOWN
Waitms 500
Lowerline : Lcd " FUOCO SPENTO"
Reset Portb.4 'luci case DOWN
Waitms 500
Lowerline : Lcd "LUCI CASE SPENTE"
Reset Portb.1 'stelle DOWN
Waitms 500
Lowerline : Lcd "STELLE SPENTE"
Reset Portd.4 ' luce notte DOWN
Lowerline : Lcd "LUCI NOTTE SPENTE"
Cls : Lcd "PROGRAMMA CARLO"
Lowerline : Lcd " CONCLUSO "
Print "PROGRAMMA_CARLO_CONCLUSO"
Waitms 1000
Goto Avvio
End
Last edited by massibal on 07 Sep 2012, 13:39, edited 1 time in total.
User avatar
massibal
 
Posts: 79
Joined: 06 Aug 2012, 11:08

Re: bascom arduino - presepio

Postby flz47655 » 05 Sep 2012, 11:30

Ciao e benvenuto,
Alcune domande che mi vengono in mente (sempre che non sia il sw):
- Hai un condensatore di disaccoppiamento vicino al display?
- Sei su breadboard?
- Hai un oscilloscopio per fare delle verifiche?
- L'alimentazione è sufficiente, l'alimentatore è ben dimensionato?
- Puoi pubblicare lo schema del circuito?

Ciao
Last edited by flz47655 on 05 Sep 2012, 11:50, edited 1 time in total.
flz47655
 
Posts: 639
Joined: 19 Jan 2012, 21:16

Re: bascom arduino - presepio

Postby deluca » 05 Sep 2012, 11:49

ciao massibal
per avere un supporto concreto dovresti allegare il sorgente così ci togliamo il bubbio sul codice, ok?

eventualmente cercheremo altrove.
ciao
Ciao
Il mio sito: http://www.delucagiovanni.com ......e la chat: chat/
User avatar
deluca
Site Admin
 
Posts: 1104
Joined: 19 Jun 2011, 10:44
Location: 95123 - Catania (Italy)

Re: bascom arduino - presepio

Postby massibal » 10 Sep 2012, 11:25

massibal wrote:salve a tutti...e grazie per le risposte!
rispondo :
Hai un condensatore di disaccoppiamento vicino al display? NO
- Sei su breadboard? SI
- Hai un oscilloscopio per fare delle verifiche? NO
- L'alimentazione è sufficiente, l'alimentatore è ben dimensionato? SI
- Puoi pubblicare lo schema del circuito? NO

sotto riporto però il file del programmino.... chiedo scusa in anticipo per eventuali castronerie .. !

grazie e buon week end

papà Massi



' **********************************************************************
' * File: presepemax_2012.bas - Rel. x.n del 04.05.12 by Max B:
' * Scheda: ARDUINO UNO con Bascom AVR
' * PROVE Funz.con sheda ARDUINO e BascomAVR
' **********************************************************************
'
'****************** Direttive del compilatore **************************
'
$regfile = "m328pdef.dat"
$crystal = 16000000
$baud = 19200
Config Clockdiv = 2

Config Pind.3 = Input ' echo
Config Portd.2 = Output ' trigger
Config Portb = Output
Config Portd.7 = Output
Config Portd.4 = Output

'$sim
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
Config Timer0 = Pwm , Prescale = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
Config Timer2 = Pwm , Prescale = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
Config Debounce = 50
'Config Adc = Single , Prescaler = Auto , Reference = Internal

'****************** Dichiarazione delle costanti ***********************
'
Const Mas = " PRESEPE 2012 "
'
'****************** Dichiarazione delle variabili **********************
'
Dim N As Byte , I As Byte , A As Byte
Dim Var As String * 1
Dim Su As Byte , Giu As Byte
Dim Tempo As Word
Dim Dist As Word
'
'************************* Programma main ******************************
'
Disable Interrupts 'Disabilita interrupt
Cls : Cursor Off 'Inizializza LCD
Lcd Mas
Print Mas
Waitms 2500
Cls
Lcd "Test comandi ON"
Print "Test comandi ON"
For N = 0 To 7
Portb = 2 ^ N
Waitms 20
Next
Set Portd.7
Waitms 50
Reset Portd.7
Waitms 50
Set Portd.4
Waitms 50
Reset Portd.4
Waitms 50
Reset Portb.0
Pwm2a = 0
Waitms 50
Pwm2a = 255
Cls
Lcd "Test comandi OFF"
Print "Test comandi OFF"
Waitms 200

Avvio:
Cls
Print "Avvia il Presepio "
Upperline
Lcd " Avvia il "
Lowerline
Lcd " presepio "
Via:
Waitms 20
' Portd.2 = 1

Pulseout Portd , 2 , 400
'Portd.2 = 0

Pulsein Tempo , Pind , 3 , 1
Tempo = Tempo * 10
Dist = Tempo / 29
If Dist < 4 Then
Gosub Programma
Elseif Dist >= 4 Then
Goto Via
Waitms 10
Cls
End If
Programma:
Print "PROGRAMMA_CARLO_ON"
Cls
Lcd "PROGRAM_CARLO_ON"
For A = 1 To 16
Shiftlcd Right
Waitms 300
Next
For A = 1 To 16
Shiftlcd Left
Waitms 300
Next

For Su = 255 To 0 Step -1
Pwm2a = Su 'accende gradatamente LUCI_GIORNO
If Su = 150 Then Set Portb.2 ' fontana UP
If Su = 120 Then Set Portd.7 ' pastori (treno)-nonna UP
If Su = 100 Then Set Portb.5 ' panni stesi - UP
Waitms 20
Next
Waitms 1000
For Giu = 0 To 255
Pwm2a = Giu 'spegne gradatamente LUCI_GIORNO
If Giu = 50 Then Reset Portd.7 ' pastori (treno)-nonna DOWN
If Giu = 80 Then Reset Portb.5 'panni stesi - DOWN
If Giu = 120 Then Reset Portb.2 'fontana DOWN
If Giu = 150 Then Set Portb.0 'fuoco UP
Waitms 20
Next
Portb.1 = 1 'stelle UP
Waitms 500
Lowerline : Lcd "STELLE ACCESE"
Set Portb.4 'luci case UP
Waitms 500
Lowerline : Lcd "LUCI CASE ACCESE"
Set Portd.4 ' luce notte UP
Waitms 500
Lowerline : Lcd "LUCE NOTTE ACCESE"
Reset Portb.0 'fuoco DOWN
Waitms 500
Lowerline : Lcd " FUOCO SPENTO"
Reset Portb.4 'luci case DOWN
Waitms 500
Lowerline : Lcd "LUCI CASE SPENTE"
Reset Portb.1 'stelle DOWN
Waitms 500
Lowerline : Lcd "STELLE SPENTE"
Reset Portd.4 ' luce notte DOWN
Lowerline : Lcd "LUCI NOTTE SPENTE"
Cls : Lcd "PROGRAMMA CARLO"
Lowerline : Lcd " CONCLUSO "
Print "PROGRAMMA_CARLO_CONCLUSO"
Waitms 1000
Goto Avvio
End
User avatar
massibal
 
Posts: 79
Joined: 06 Aug 2012, 11:08

Re: bascom arduino - presepio

Postby deluca » 10 Sep 2012, 13:26

scusa massibal, ma non riesco a trovare il tuo topic iniziale dove spiegavi i problemi che avevi incontrato con questo circuito.
potresti gentilmente rimembrare cosa ti accadeva ?

grazie

un consiglio:
quando vai con la stesura del sorgente prova a dare una formattazione strutturale....
ti aiuterà e ci aiuterà molto a interpretare prima il codice. (la prossima volta) :)

PS. Come sensore distanza stai impiegando SRF quale modello?

ciao
Ciao
Il mio sito: http://www.delucagiovanni.com ......e la chat: chat/
User avatar
deluca
Site Admin
 
Posts: 1104
Joined: 19 Jun 2011, 10:44
Location: 95123 - Catania (Italy)

Re: bascom arduino - presepio

Postby massibal » 11 Sep 2012, 08:00

Buongiorno ,
il modello del sensore è SFR05.

il problema è che volevo utilizzare il sensore come "interruttore" per fare partire il ciclo del presepe con un movimento della mano.

fintanto che non ho installato un display lcd 16x2 andava tutto bene ora che c'è anche il lcd il sensore parte a caso e non so come fare .

se cìè una soluzione software o se devo modificare hardware!!

grazie mille

cordiali saluti

PS mi scuso pe l'ignoranza ma mi potresti fare un esempio su cosa si intende per formattazione strutturale?

massi
User avatar
massibal
 
Posts: 79
Joined: 06 Aug 2012, 11:08

Re: bascom arduino - presepio

Postby deluca » 11 Sep 2012, 08:16

intanto inizia con il sostituire :

Pulseout Portd , 2 , 400
Pulsein Tempo , Pind , 3 , 1

con

Code: Select all
Pulseout Portd , 2 , 20         'genera impulso trigger 20uSec
Bitwait Pind.3 , Reset           'aspetta che il pin cambi di stato
Pulsein Tempo , Pind , 3 , 1   'misura il periodo dell'impulso echo


es: formattazione strutturata del tuo codice

Code: Select all
Via:
Waitms 20
 ' Portd.2 = 1

Pulseout Portd , 2 , 400
 'Portd.2 = 0

Pulsein Tempo , Pind , 3 , 1
   Tempo = Tempo * 10
   Dist = Tempo / 29

   If Dist < 4 Then
      Gosub Programma
   Elseif Dist >= 4 Then
      Goto Via
      Waitms 10
      Cls
   End If
'-------------------------------------------------------------------------------
Programma:
Print "PROGRAMMA_CARLO_ON"
Cls
 Lcd "PROGRAM_CARLO_ON"
   For A = 1 To 16
      Shiftlcd Right
      Waitms 300
   Next
   For A = 1 To 16
         Shiftlcd Left
         Waitms 300
   Next

 For Su = 255 To 0 Step -1
   Pwm2a = Su                                               'accende gradatamente LUCI_GIORNO
   If Su = 150 Then Set Portb.2                             ' fontana UP
   If Su = 120 Then Set Portd.7                             ' pastori (treno)-nonna UP
   If Su = 100 Then Set Portb.5                             ' panni stesi - UP
   Waitms 20
 Next


PS. modificando la external sub [_PULSE_IN] della libreria "mcs.lib" potresti incrementare notevolmente la risoluzione di TEMPO.
ma se non hai abbastanza dimestichezza con l'assembly meglio lasciar perdere.

ciao
Ciao
Il mio sito: http://www.delucagiovanni.com ......e la chat: chat/
User avatar
deluca
Site Admin
 
Posts: 1104
Joined: 19 Jun 2011, 10:44
Location: 95123 - Catania (Italy)

Re: bascom arduino - presepio

Postby massibal » 13 Sep 2012, 15:49

buonasera,
ti ringrazio molto per l'aiuto..

quando torno a casa mi metto al lavoro!

buonaserata.

massibal
User avatar
massibal
 
Posts: 79
Joined: 06 Aug 2012, 11:08

Re: bascom arduino - presepio

Postby massibal » 19 Sep 2012, 17:58

grazie mille ...

tutto perfetto !

procedo con il mio progetto ... adesso sono alle prese con il relè del trenino!

ciao a tutti
massibal
User avatar
massibal
 
Posts: 79
Joined: 06 Aug 2012, 11:08

Re: bascom arduino - presepio

Postby omega25 » 19 Sep 2012, 20:43

massibal,
cosa intendi quando dici "tutto perfetto !" con l'esclamazione?
ho capito che il tuo programma adesso va bene.....

potresti spiegarci quali modifiche sono state apportate?
omega25
 
Posts: 24
Joined: 04 Aug 2012, 09:33

Re: bascom arduino - presepio

Postby massibal » 20 Sep 2012, 09:11

Si scusate ,
il mio problema era il sensore ad ultrasuoni, dopo aver modificato le istruzioni, come da indicazione del "grande" (come dice mio filgio e io condivido anche se utilizzerei un aggettivo più appropriato) deluca, adesso il sensore fa la funzione che deve fare cioè da interruttore per avvirar il ciclo del presepio.

saluti a tutti
massibal
User avatar
massibal
 
Posts: 79
Joined: 06 Aug 2012, 11:08


Return to BASCOM-AVR

Who is online

Users browsing this forum: No registered users and 4 guests

cron