Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Analogic Clcok with the gauges of nextion HMI

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 987
Location: France

france.gif
PostPosted: Fri Dec 18, 2020 12:07 pm    Post subject: Analogic Clcok with the gauges of nextion HMI Reply with quote

Hi

This video shows the interest of using the "intelligent" Nextion .
the gauges have the possibility to be transparent, i.e. the hand is displayed but not the background.
This considerably reduces the number of programme lines.
Moreover I used the internal RTC which frees an I2C port.


Again this is possible only with the "intelligente Nextion display
[img][/img]
Video here : https://youtu.be/rZ9rJepxNWU



code here :

JP Wink

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5205
Location: Holland

blank.gif
PostPosted: Fri Dec 18, 2020 9:19 pm    Post subject: Reply with quote

thank you for sharing JP.
Time is going fast in the video Very Happy
It looks smooth.
In 2021 i will check out nextion too.

_________________
Mark
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 987
Location: France

france.gif
PostPosted: Sun Dec 20, 2020 2:25 pm    Post subject: a little bug Reply with quote

the intervals are sometimes difficult to handle. it's just arithmetic and I made a little mistake that my 9 year old granddaughter won't forgive me. Wink the correct sub in nextiontimedate.inc for hour is:
Code:
'----------------------------------------------------------------------------------------
Sub Gaugehour()                                             'pour calculer l'angle de la gauge minutes en fonctions des minutes
   Local Fxmin As Word
   Local Fxhour As Word
  Fxhour = Jhour
   Select Case Fxhour
       Case 0 To 8
       Fxhour = Fxhour * 30 : Fxhour = Fxhour + 90
      Case 9 To 12
         Fxhour = Fxhour -9 : Fxhour = Fxhour * 30          'sans les minutes
      Case 13 To 20
          Fxhour = Fxhour - 12
          Fxhour = Fxhour * 30
           Fxhour = Fxhour + 90                             'sans les minutes
          Case 21 To 23
          Fxhour = Fxhour - 21 : Fxhour = Fxhour * 30
   End Select
   Fxmin = Jminute : Fxmin = Fxmin \ 2                      'on ajoute le décalage des minutes ,
   ' 60 minutes de décallage dans l'heure  pleine pour 30 degrés Donc division entière des minutes
   ' Et Incément Toutes Les 2 Minutes.
   Fxhour = Fxhour + Fxmin

  Call Nex_gaugeval( "z1" , Fxhour)
End Sub

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 987
Location: France

france.gif
PostPosted: Sun Dec 27, 2020 6:44 pm    Post subject: letter weighing with a HX711 Reply with quote

I have added a letter weighing function to my clock.
I was helped by Mikael from the Bascom.de forum. You can see the software I used as an inspiration.
https://bascomforum.de/index.php?thread/1644-load-cell-sensor-hx711/&postID=27108#post27108
many thanks to him for this very simple way to do

I use a DFROBOT SEN160 1Kg module from GoTronic to do it
the Video :
https://youtu.be/-D6NelyDm-U

the code :
I remark the dim because they are put in the main program.


Code:
''HX711 weight----------------------------------------------


Sub Hx711()
'HX711 Wägezellen-Sensor michael@bascomforum.de
   Call Nex_page(2)                                         'give here the name of the weight page==============
   Waitms 100

'Dim Wert As Long                                            'Wandlerwert        Converter value        Valeur du convertisseur
'Dim C As Byte At Wert Overlay                            'serielles Byte LSB
'Dim B As Byte At Wert + 1 Overlay
'Dim A As Byte At Wert + 2 Overlay                           'serielles Byte MSB
'Dim X As Byte At Wert + 3 Overlay                           'MSB im Long
'Dim Tara As Long                                            'Offset
'Dim Wert_final As Long                                      'Rechnungsvariable
'Const Faktor = 1989

   Clock Alias Portc.5                                         ' the clock
   Config Clock = Output
   D_in Alias Pinc.4                                        ' data in
   Config D_in = Input

   Tara = 0
   Do
      For Ibyte = 7 To 0 Step -1
         Clock = 1
         Waitus 2
         A.ibyte = D_in
         Waitus 1
         Clock = 0
      Next
      If A.7 = 1 Then
         X = 255
      Else
         X = 0
      End If
      For Ibyte = 7 To 0 Step -1
         Clock = 1
         Waitus 2
         B.ibyte = D_in
         Waitus 1
         Clock = 0
      Next
      For Ibyte = 7 To 0 Step -1
         Clock = 1
         Waitus 2
         C.ibyte = D_in
         Waitus 1
         Clock = 0
      Next
      Clock = 1                                                '25 Clocks
      Waitus 2
      Waitus 1
      Clock = 0
      Waitms 20
      Device_id = 0
      Call Nex_returntime()
      Select Case Device_id
         Case 1                                             'tare
            Tara = Wert
            Debug #usb , "tare:" ; Wert
            Device_id = 0
            Wait 1
           Case 2                                           'retour
             Exit Sub

      End Select
      Waitms 200
      If Tara = 0 Then Call Nex_text( "t3" , "Zero ?" , Black , White , 4)
      Call Weighing()

   Loop
End Sub

Sub Weighing()
   If Tara > 0 Then
      Wert = Wert - Tara                                    'Offset abziehen    'deduct offset (tare) , soustraire le décalage
   End If
   If Tara = 0 Then
      Call Nex_text( "t3" , "Zero ?" , Black , White , 4)
       Debug #usb , "mesure vide " ; Wert
      Exit Sub
   End If
  Wert_final = Wert / Faktor                                'Faktor für metrische Gramm   Factor for metric grams        ' facteur pour les grammes
   Wert_final = Abs(wert_final)
   Debug #usb , "Wert_final " ; Wert_final
   Sentence = Str(wert_final) : Sentence = Sentence + " g"
   Call Nex_text( "t3" , Sentence , Black , White , 4)
   Device_id = 0
End Sub

_________________
pleasure to learn, to teach, to create


Last edited by Duval JP on Mon Dec 28, 2020 10:56 am; edited 1 time in total
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5205
Location: Holland

blank.gif
PostPosted: Mon Dec 28, 2020 10:53 am    Post subject: Reply with quote

hi JP

thanks for the video and this addition.
it seems to be very accurate.

Ha Michael , he can do about anything with bascom Very Happy

_________________
Mark
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 987
Location: France

france.gif
PostPosted: Mon Dec 28, 2020 11:01 am    Post subject: Reply with quote

yes that right . Mikael use overlay and with this sample I understand overlay with the MSB and LSB Wink
JP

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum