Line Touch Sensor

    Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

    Aufgrund technischer Veränderungen ist der Mailverkehr innerhalb des Forums (Private Nachrichten) nur noch eingeschränkt möglich. Die Einschränkung ist notwendig, um zusätzliche Betriebskosten für das Forum zu vermeiden. Näheres zu den Hintergründen im Thread "Aktuelles zum Forum".Wir bitten um Verständnis.

    Hinweis kann nach Kenntnisnahme deaktiviert werden!

    • Line Touch Sensor

      Ich habe ein paar Touch-Sensormodule mit einem MPR121 (Freescale) in die Hände bekommen.
      Das Modul hat 12 Sensorfelder und der Chip als Komunikationsweg I²C plus einen IRQ-Ausgang der aktiv(0) wird wenn sich an den Sensorfeldern etwas ändert.

      nxp.com/docs/en/data-sheet/MPR121.pdf

      Der MPR121 wird zwar nicht mehr produziert, aber die Module sind zu Hauf (noch) beim freundlichen Chinesen u. a. zu bekommen. Leider war kein Bascom-Code zu finden.
      Also diy:

      BASCOM-Quellcode

      1. '-------------------------------------------------------------------------------
      2. '
      3. 'Touch Sensor
      4. 'MPR121 (freescale) A C H T U N G ! VCC=3,3V >>>> Pegelwandler verwenden!
      5. '.............................................oder 3V3 µC-Board
      6. 'Arduino NANO / UNO ........o.ä.
      7. '
      8. 'Nov.2018 by Mandarin15
      9. '
      10. 'Demo mit Minimal-Konfiguration
      11. '
      12. '-------------------------------------------------------------------------------
      13. $regfile = "m328pdef.dat"
      14. $crystal = 16000000
      15. $hwstack = 64
      16. $swstack = 32
      17. $framesize = 64
      18. Config Portb.5 = Output
      19. Led Alias Portb.5
      20. '________________________________________________________________________________Register lt. Datenblatt / AN3944
      21. Mhd_rising Alias &H2B
      22. Nhd_amount_rising Alias &H2C
      23. Ncl_rising Alias &H2D
      24. Fdl_rising Alias &H2E
      25. Mhd_falling Alias &H2F
      26. Nhd_amount_falling Alias &H30
      27. Ncl_falling Alias &H31
      28. Fdl_falling Alias &H32
      29. Ele0_touch_threshold Alias &H41
      30. Ele0_release_threshold Alias &H42
      31. Ele1_touch_threshold Alias &H43
      32. Ele1_release_threshold Alias &H44
      33. Ele2_touch_threshold Alias &H45
      34. Ele2_release_threshold Alias &H46
      35. Ele3_touch_threshold Alias &H47
      36. Ele3_release_threshold Alias &H48
      37. Ele4_touch_threshold Alias &H49
      38. Ele4_release_threshold Alias &H4A
      39. Ele5_touch_threshold Alias &H4B
      40. Ele5_release_threshold Alias &H4C
      41. Ele6_touch_threshold Alias &H4D
      42. Ele6_release_threshold Alias &H4E
      43. Ele7_touch_threshold Alias &H4F
      44. Ele7_release_threshold Alias &H50
      45. Ele8_touch_threshold Alias &H51
      46. Ele8_release_threshold Alias &H52
      47. Ele9_touch_threshold Alias &H53
      48. Ele9_release_threshold Alias &H54
      49. Ele10_touch_threshold Alias &H55
      50. Ele10_release_threshold Alias &H56
      51. Ele11_touch_threshold Alias &H57
      52. Ele11_release_threshold Alias &H58
      53. Filter_cfg Alias &H5D
      54. Electrode_cfg Alias &H5E
      55. Gpio_ctrl_reg_0 Alias &H73 'GPIO auf meinem Board nicht verfügbar
      56. Gpio_ctrl_reg_1 Alias &H74
      57. Gpio_data_reg Alias &H75
      58. Gpio_dir_ctrl_reg Alias &H76
      59. Gpio_enable_reg Alias &H77
      60. Gpio_data_set_reg Alias &H78
      61. Gpio_data_clear_reg Alias &H79
      62. Gpio_data_toggle_reg Alias &H7A
      63. Auto_cfg_control_0 Alias &H7B
      64. Auto_cfg_usl Alias &H7D
      65. Auto_cfg_lsl Alias &H7E
      66. Auto_cfg_target_level Alias &H7F
      67. Touch_threshold Alias &H0F
      68. Release_threshold Alias &H0A
      69. Mpr121_read_adr Alias &HB5
      70. Mpr121_write_adr Alias &HB4
      71. '_______________________________________________________________________________
      72. Dim Touch As Boolean 'Neue Daten von MPR121
      73. Dim Touchstatus As Word
      74. Dim Touchstatus_l As Byte At Touchstatus Overlay
      75. Dim Touchstatus_h As Byte At Touchstatus + 1 Overlay
      76. Config Pind.2 = Input 'IRQ! von MPR121 (Active Low Open-drain Interrupt Output)
      77. Portd.2 = 1 'Pullup
      78. Config Int0 = Falling 'PIND.2
      79. Enable Int0
      80. On Int0 Int0_irq
      81. $lib "i2c_TWI.lib"
      82. Config Scl = Portc.5 'Ports fuer IIC-Bus
      83. Config Sda = Portc.4
      84. Config Twi = 400000
      85. Config Com1 = 115200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 'USB_debug
      86. Declare Sub Mpr121write(byval Reg_address As Byte , Byval Daten As Byte)
      87. Declare Function Mpr121read(byval Read_register As Byte ) As Byte
      88. '-------------------------------------------------------------------------------
      89. I2cinit
      90. Gosub Mpr121config
      91. Enable Interrupts
      92. Print "START MPR121 Demo"
      93. '###############################################################################
      94. '###############################################################################
      95. Do
      96. If Touch = 1 Then
      97. Print Bin(touchstatus)
      98. Touch = 0
      99. Led = 0
      100. End If
      101. Loop
      102. '###############################################################################
      103. '###############################################################################
      104. '_______________________________________________________________________________
      105. Int0_irq:
      106. 'MPR121 Irq
      107. Touchstatus_l = Mpr121read(&H00)
      108. Touchstatus_h = Mpr121read(&H01)
      109. Touch = 1 'neue Daten
      110. Led = 1
      111. Return
      112. '_______________________________________________________________________________
      113. Mpr121config:
      114. 'Section A
      115. 'This group of setting controls the filtering of the system when the data is greater than the baseline
      116. Call Mpr121write(mhd_rising , &H01)
      117. Call Mpr121write(nhd_amount_rising , &H01)
      118. Call Mpr121write(ncl_rising , &H00)
      119. Call Mpr121write(fdl_rising , &H00)
      120. 'Section B
      121. 'This group of setting controls the filtering of the system, when the data is less than the baseline
      122. Call Mpr121write(mhd_falling , &H01)
      123. Call Mpr121write(nhd_amount_falling , &H01)
      124. Call Mpr121write(ncl_falling , &HFF)
      125. Call Mpr121write(fdl_falling , &H02)
      126. 'Section C
      127. 'The touch threshold registers set the minimum delta from the baseline when a touch is detected
      128. Call Mpr121write(ele0_touch_threshold , Touch_threshold)
      129. Call Mpr121write(ele0_release_threshold , Release_threshold)
      130. Call Mpr121write(ele1_touch_threshold , Touch_threshold)
      131. Call Mpr121write(ele1_release_threshold , Release_threshold)
      132. Call Mpr121write(ele2_touch_threshold , Touch_threshold)
      133. Call Mpr121write(ele2_release_threshold , Release_threshold)
      134. Call Mpr121write(ele3_touch_threshold , Touch_threshold)
      135. Call Mpr121write(ele3_release_threshold , Release_threshold)
      136. Call Mpr121write(ele4_touch_threshold , Touch_threshold)
      137. Call Mpr121write(ele4_release_threshold , Release_threshold)
      138. Call Mpr121write(ele5_touch_threshold , Touch_threshold)
      139. Call Mpr121write(ele5_release_threshold , Release_threshold)
      140. Call Mpr121write(ele6_touch_threshold , Touch_threshold)
      141. Call Mpr121write(ele6_release_threshold , Release_threshold)
      142. Call Mpr121write(ele7_touch_threshold , Touch_threshold)
      143. Call Mpr121write(ele7_release_threshold , Release_threshold)
      144. Call Mpr121write(ele8_touch_threshold , Touch_threshold)
      145. Call Mpr121write(ele8_release_threshold , Release_threshold)
      146. Call Mpr121write(ele9_touch_threshold , Touch_threshold)
      147. Call Mpr121write(ele9_release_threshold , Release_threshold)
      148. Call Mpr121write(ele10_touch_threshold , Touch_threshold)
      149. Call Mpr121write(ele10_release_threshold , Release_threshold)
      150. Call Mpr121write(ele11_touch_threshold , Touch_threshold)
      151. Call Mpr121write(ele11_release_threshold , Release_threshold)
      152. 'Section D
      153. 'There are three settings embedded in this register so it is only necessary to pay attention to one
      154. Call Mpr121write(filter_cfg , &H04)
      155. 'Section E
      156. 'Electrode Configuration
      157. Call Mpr121write(electrode_cfg , &H0C) 'Enable 12 Electrodes
      158. 'Section F
      159. 'Enable Auto Config and auto Reconfig
      160. 'call mpr121Write(Auto_cfg_control_0, &H0B)
      161. 'call Mpr121write(Auto_cfg_usl , &H9C)
      162. 'call Mpr121write(Auto_cfg_lsl , &H65)
      163. 'call Mpr121write(Auto_cfg_target_level , &H8C)
      164. Return
      165. '_______________________________________________________________________________
      166. Sub Mpr121write(byval Reg_address As Byte , Byval Daten As Byte)
      167. I2cstart
      168. I2cwbyte Mpr121_write_adr 'write 0xB4
      169. I2cwbyte Reg_address 'write register reg_Address
      170. I2cwbyte Daten
      171. I2cstop
      172. End Sub
      173. '_______________________________________________________________________________
      174. Function Mpr121read(byval Read_register As Byte ) As Byte
      175. Local Read_data As Byte
      176. I2cstart
      177. I2cwbyte Mpr121_write_adr
      178. I2cwbyte Read_register
      179. I2crepstart
      180. I2cwbyte Mpr121_read_adr
      181. I2crbyte Read_data , Nack
      182. I2cstop
      183. Mpr121read = Read_data
      184. End Function
      185. '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      186. End
      Alles anzeigen


      Die Software basiert auf der App. Note 3944 vom Hersteller:
      nxp.com/docs/en/application-note/AN3944.pdf

      Bei der Hardware ist zu beachten, das der MPR121 mit 3,3V läuft. Es gibt aber auch Module die den Pegelwandler schon integriert haben.

      LG
    • Vielen herzlichen Dank für diesen Post und die Source. Ich konnte damit einen Zahlenkonverter ganz einfacher Art, so wie ich ihn wollte, realisieren. Ich weiß, der Post ist aus 2018, aber trotzdem möchte ich dazu eine Frage stellen:
      Mein Zahlenkonverter funktioniert einwandfrei. Allerdings reagiert der erste Tastendruck erst nach ca. 8 sec. Danach gibt es keine Probleme mehr. Ich habe die Source schon zigmal durchgesehen, kann aber keine Verzögerung finden. Hat jemand aus dem Forum eine Idee?

      BASCOM-Quellcode: Zahlenkonverter

      1. '(
      2. -------------------------------------------------
      3. Konverter für Zahlensysteme
      4. dez, hex, bin
      5. JM 5/2023
      6. V.0.2
      7. 2 x Touchpad MPR121 (I2C)
      8. LCD (I2C)
      9. --------------------------------------------------
      10. PC4 = SDA
      11. PC5 = SCL
      12. PD2 = INT0
      13. PD3 = INT1
      14. ---------- Konfiguration -------------------------
      15. ')
      16. $Regfile="m8def.dat"
      17. $Crystal=8000000
      18. $hwstack=40
      19. $swstack=30
      20. $framesize=40
      21. $PROG &HFF,&HC4,&HD9,&H00'
      22. $lib "YwRobot_Lcd_i2c.lib"
      23. config Lcd=20 * 4
      24. config I2cdelay= 1
      25. config Scl=Portc.5
      26. config Sda=Portc.4
      27. Config Pind.2 = Input
      28. Portd.2 = 1
      29. Config Int0 = Falling
      30. Enable Int0
      31. On Int0 Int0_irq
      32. Config Pind.3 = Input 'IRQ! von MPR121 (Active Low Open-drain Interrupt Output)
      33. Portd.3 = 1 'Pullup
      34. Config Int1 = Falling 'PIND.2
      35. Enable Int1
      36. On Int1 Int1_irq
      37. const Pcf8574_lcd=78
      38. Const Pcf_d4 = 4
      39. Const Pcf_d5 = 5
      40. Const Pcf_d6 = 6
      41. Const Pcf_d7 = 7
      42. Const Pcf_rs = 0
      43. Const Pcf_rw = 1
      44. Const Pcf_e2 = 3
      45. Const Pcf_e1 = 2
      46. const mprrd1=&HB5
      47. const mprwr1=&HB4
      48. const mprrd2=&HB7
      49. const mprwr2=&HB6
      50. i2cinit
      51. '--------- Variable ------------------------------
      52. dim _lcd_e As Byte
      53. dim Lcd_backlight As Byte
      54. dim key1 as word
      55. dim key1l as byte at key1 overlay
      56. dim key1h as byte at key1 + 1 overlay
      57. dim key2 as word
      58. dim key2l as byte at key2 overlay
      59. dim key2h as byte at key2 + 1 overlay
      60. dim mpr_adr as byte
      61. dim eingabe as string *1
      62. dim ausgabe as string *16
      63. dim wert as word
      64. dim auswahl as string*1
      65. dim pressed1 as byte
      66. dim pressed2 as byte
      67. dim reg as byte
      68. dim dat as byte
      69. declare sub conf1 (byval reg as byte,byval dat as byte)
      70. declare sub write_value (byval eingabe as string)
      71. declare sub setauswahl (byval eingabe as string)
      72. '--------- Hauptprogramm -------------------------
      73. _lcd_e = 128
      74. Lcd_backlight = 1
      75. cls
      76. mpr_adr=mprwr1
      77. gosub setmpr
      78. mpr_adr=mprwr2
      79. gosub setmpr
      80. pressed1=0
      81. pressed2=0
      82. auswahl=""
      83. enable interrupts
      84. cursor on
      85. Do
      86. if pressed1=1 and key1<>0 then
      87. select case key1
      88. case 128:call write_value ("0")
      89. case 1024:call write_value ("1")
      90. case 64:call write_value ("2")
      91. case 4:call write_value ("3")
      92. case 512:call write_value ("4")
      93. case 32:call write_value ("5")
      94. case 2:call write_value ("6")
      95. case 256:call write_value ("7")
      96. case 16:call write_value ("8")
      97. case 1:call write_value ("9")
      98. end select
      99. pressed1=0
      100. end if
      101. if pressed2=1 and key2<>0 then
      102. select case key2
      103. case 128:gosub padcls
      104. case 1024:call setauswahl ("d")
      105. case 64:call setauswahl ("h")
      106. case 4:call setauswahl ("b")
      107. case 512:call write_value ("D")
      108. case 32:call write_value ("E")
      109. case 2:call write_value ("F")
      110. case 256:call write_value ("A")
      111. case 16:call write_value ("B")
      112. case 1:call write_value ("C")
      113. end select
      114. pressed2=0
      115. end if
      116. Loop
      117. '--------- Unterprogramme ------------------------
      118. sub conf1 (byval reg as byte,byval dat as byte)
      119. i2cstart
      120. i2cwbyte mpr_adr
      121. i2cwbyte reg
      122. i2cwbyte dat
      123. i2cstop
      124. end sub
      125. '---------------------------------------------------
      126. setmpr:
      127. call conf1 (&h2b,&h01)
      128. call conf1 (&h2c,&h01)
      129. call conf1 (&h2d,&h00)
      130. call conf1 (&h2e,&h00)
      131. call conf1 (&h2f,&h01)
      132. call conf1 (&h30,&h01)
      133. call conf1 (&h31,&hff)
      134. call conf1 (&h32,&h02)
      135. call conf1 (&h41,&h0f)
      136. call conf1 (&h42,&h0a)
      137. call conf1 (&h43,&h0f)
      138. call conf1 (&h44,&h0a)
      139. call conf1 (&h45,&h0f)
      140. call conf1 (&h46,&h0a)
      141. call conf1 (&h47,&h0f)
      142. call conf1 (&h48,&h0a)
      143. call conf1 (&h49,&h0f)
      144. call conf1 (&h4a,&h0a)
      145. call conf1 (&h4b,&h0f)
      146. call conf1 (&h4c,&h0a)
      147. call conf1 (&h4d,&h0f)
      148. call conf1 (&h4e,&h0a)
      149. call conf1 (&h4f,&h0f)
      150. call conf1 (&h50,&h0a)
      151. call conf1 (&h51,&h0f)
      152. call conf1 (&h52,&h0a)
      153. call conf1 (&h53,&h0f)
      154. call conf1 (&h54,&h0a)
      155. call conf1 (&h55,&h0f)
      156. call conf1 (&h56,&h0a)
      157. call conf1 (&h57,&h0f)
      158. call conf1 (&h58,&h0a)
      159. call conf1 (&h5d,&h04)
      160. call conf1 (&h5e,&h0c)
      161. return
      162. '---------------------------------------------------
      163. padcls:
      164. ausgabe=""
      165. eingabe=""
      166. 'auswahl=""
      167. cls
      168. return
      169. '---------------------------------------------------
      170. sub setauswahl (byval eingabe)
      171. if auswahl>"" then exit sub
      172. select case eingabe
      173. case "d":auswahl="d"
      174. case "h":auswahl="h"
      175. case "b":auswahl="b"
      176. end select
      177. locate 1,18
      178. select case auswahl
      179. case "d":lcd "dez"
      180. case "h":lcd "hex"
      181. case "b":lcd "bin"
      182. end select
      183. eingabe=""
      184. locate 1,1
      185. end sub
      186. '---------------------------------------------------
      187. sub write_value (byval eingabe)
      188. if auswahl="" then gosub padcls
      189. if auswahl="" then exit sub
      190. if auswahl="d" and len(ausgabe)=5 then exit sub
      191. if auswahl="h" and len(ausgabe)=4 then exit sub
      192. if auswahl="b" and len(ausgabe)=16 then exit sub
      193. if auswahl="b" and eingabe<>"0" and eingabe<>"1" then exit sub
      194. if auswahl="d" and eingabe>"9" then exit sub
      195. dim binwert as string*17
      196. ausgabe=ausgabe+eingabe
      197. if auswahl="d" then wert=val(ausgabe)
      198. if auswahl="h" then wert=hexval(ausgabe)
      199. if auswahl="b" then wert=binval(ausgabe)
      200. locate 1,1
      201. lcd ausgabe
      202. locate 2,1
      203. binwert=bin (wert)
      204. insertchar binwert,9," "
      205. lcd "b: ";binwert
      206. locate 3,1
      207. lcd "d: ";wert
      208. locate 4,1
      209. lcd "$: ";hex (wert)
      210. end sub
      211. '---------------------------------------------------
      212. end
      213. Int0_irq:
      214. 'MPR121 Irq
      215. I2cstart
      216. I2cwbyte Mprwr1
      217. I2cwbyte &h00
      218. I2crepstart
      219. I2cwbyte Mprrd1
      220. I2crbyte key1l,ack
      221. i2crbyte key1h,nack
      222. I2cstop
      223. pressed1 = 1
      224. return
      225. '---------------------------------------------------
      226. Int1_irq:
      227. 'MPR121 Irq
      228. I2cstart
      229. I2cwbyte Mprwr2
      230. I2cwbyte &h00
      231. I2crepstart
      232. I2cwbyte Mprrd2
      233. I2crbyte key2l,ack
      234. i2crbyte key2h,nack
      235. I2cstop
      236. pressed2 = 1
      237. Return
      238. '---------------------------------------------------
      Alles anzeigen
    • Das erklärt die acht Sekunden nicht, aber mit

      jogiavr schrieb:

      config I2cdelay= 1
      wird das I2C in Software ausgeführt und schafft vermulich kein MHz. ( bei 8MHz Takt)
      Mit $lib "i2c_twi.lbx" wird der Hardware TWI(I2C) genutzt und der schafft bei 8MHz Takt 444Khz (500Khz?)
      Der PCF kann offiziell nur 100KHz. Bei mir gab er bei 200KHz auf ;)
      Da es bei Dir funktioniert vermute ich das das I2Cdelay nicht richtig wirkt. Versuch mal I2CDelay=10 oder besser die Hardware mit Config Twi = 100000
    • Habe heute alle deine Vorschläge ausprobiert. War kein großer Aufwand, weil bei der Umstellung zum Hardware-TWI alle anderen Parameter schon gepaßt haben. Hat aber leider nichts geändert. Trotzdem vielen Dank für deine Unterstützung!

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von jogiavr ()

    • Wär ja auch zu einfach ;(
      Da ist ein Lcd, das könnte eine Art Bootbericht abgeben z.B Init MPR1 , Init MPR2, Starte Main
      Eine Err Auswertung könnte auch aufschlußreich sein?

      Die MPR brauchen ein Weilchen wach zu werden, aber bestimmt keine 8 Sekunden :D
      Dennoch würde ein Waitms 500(?) in Zeile 102 nicht stören

      PS Das LCD arbeitet sofort (Cursor on) ? Einige werden auch zu langsam wach um das von Bascom augeführte initlcd zu verschlafen.

      PPS hat das _lcd_e und die Konstanten (Pcf_..) eine Funktion? In der YwRobot_Lcd_i2c.lib hier ( Version 1.2) werden die nicht berücksichtigt
    • Habe heute alle den Vorschläge ausprobiert. War kein großer Aufwand, weil bei der Umstellung zum Hardware-TWI alle anderen Parameter schon gepaßt haben. Hat aber leider nichts geändert. Trotzdem vielen Dank für deine Unterstützung!

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von jogiavr ()

    • Die LCD-Ausgaben habe ich gemacht. Es liegt definitiv nicht am LCD. Das meldet sich sofort. Die Initialisierung des MPR121 geht auch ratzfatz. Bei den Interrupt-Routinen habe ich auch eine LCD-Ausgabe eingebaut. Dabei ist mir aufgefallen, dass die Interrupt-Routinen nach dem Einschalten nicht angesprungen werden, wenn ich gleich eine Taste drücke. Das würde bedeuten, dass der Übeltäter im MPR121 sitzt und eine Zeitlang kein Interruptsignal bringt, obwohl eine Taste gedrückt wurde. Ich muss jetzt mal im Datenblatt nachsehen, ob es da eine Einstellung gibt, die den Kaltstart des Touchpads definiert.

      Die Funktion des lcd_e ist mir auch schleierhaft. Ich habe sie mit übernommen, als ich das erste Mal ein I2C-LCD ansteuerte. Unter dem Motto: never change a running system ;) Ich kann's versuchsweise auch mal rausnehmen. Mal sehen, was da passiert.

      Wie ihr seht, komme ich noch nicht ganz klar mit den Eintragungen im Forum. Meine erste Frage wäre: wie kann ich einen Post löschen. Auch wenn schon drauf geantwortet wurde. Immer wenn ich einen Text absende, bekomme ich eine Fehlermeldung (habe ich leider nicht kopiert). Dann sende ich nochmals ab und am Ende hätte das erste, angeblich fehlerhafte Absenden, schon funktioniert. Damit kommt es zu Doppeleinträgen. Irgenwie bin ich da vermutlich zu doof. Aber ich strenge mich an ;)
    • jogiavr schrieb:

      dass der Übeltäter im MPR121 sitzt
      In Deinen Init(Setmpr) werden die "Auto (Re)Config" Register (7B-7F) nicht geschrieben. Vielleicht versuchsweise noch
      Call Conf1(&H7b , &H0B)
      Call Conf1(&H7d , &H9C)
      Call Conf1(&H7e , &H65)
      Call Conf1(&H7f , &H8C)
      in Zeile 206 einfügen

      jogiavr schrieb:

      wie kann ich einen Post löschen
      Gar nicht, nur über eine Nachricht an einen Admin

      jogiavr schrieb:

      Damit kommt es zu Doppeleinträgen
      Das ist wohl ein verzwickter Fehler der Forensoftware. Daran wird gearbeitet. Bei mir kam er schon länger nicht mehr vor. Ist wohl System / Browserabhängig. Ich hatte mir angewöhnt den Treat in einem neuen(zweiten) Fenster zu öffnen. Damit wurde ersichtlich ob er angekommen war. Fast immer trotz Fehlermeldung.

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Pluto25 ()

    • Vielen Dank für den Hinweis. Diese Konfiguration hatte ich schon mal drin, dann aber aus irgendeinem Grund wieder rausgenommen. Ich baue sie auf jeden Fall mal wieder ein. Auch prüfe ich zuvor mit einem Oszi, ob tatsächlich kein Interruptsignal in den ersten Sekunden trotz gedrückter Taste kommt.

      Bin froh, dass ich nicht doch zu doof bin. Mich stört der Forums-Bug nicht. Nur gut zu wissen, dass es keine Fehlbedienung ist. Vielleicht schmeißt der Admin die Doppeleinträge ja selbständig raus. Falls nicht, würde ich hiermit darum bitten. Vielen Dank!
    • Leider war das nicht der Fehler. Die erweiterte Konfiguration hat das Problem nicht gelöst. Allerdings weiß ich jetzt, dass es am MPR121 liegt. Das Touchpad bringt nach dem Einschalten erst nach ca. 8 sec einen Interruptpuls bei einem Tastendruck. Die Tastenanschläge zuvor werden nicht gemeldet. Damit kann das Programm auch keine Tastenwerte einlesen. Da muss ich nochmals komplett durch das Datenblatt.
    • jogiavr schrieb:

      Die Tastenanschläge zuvor werden nicht gemeldet.
      Sind es immer 8Sekunden bei beiden? Auch dann wenn keine Taste gedrückt wird oder sehr viele?
      Das "Autoincrement " beim lesen funktioniert? Bei der Vorlage wurden die Register einzeln gelesen (wie beim Schreiben). Würde das dort auch funktionieren? Vielleicht sogar besser:
      "Bus Free Time Between a STOP and a START Condition min 1,3µs" Das arme Kerlchen bekommt ja ständig Stop Start vorm Latz geknallt :D

      Register $5D ist Default $24. Ist es denn richtig das "Electrode Charging Disabled" wird ? Ich würde das bei einem weglassen. Wenn das falsch ist meldet der einen Key von >=16384 und stopt ;(

      Die Main könnte die Key auslesen und auf dem Lcd zeigen ob die Tasten auch schon funktionieren bevor die 8 Sekunden um sind.
      Sind die auch nach einem Reset oder "nur" beim Kaltstart?
    • Klingen tut das schon nach einem umfangreichen Einmessen der Tasten
      (Größe der Felder, Kapazität, Ladezeit, Filter für Debounce) evtl. sogar mehrfach? zur Sicherheit.
      Ist aber auch komplex der Baustein.

      Einige Erklärungen sind auch in dem Dokument hier:

      nxp.com/docs/en/application-note/AN3889.pdf

      Nach einer aut. Einmessung - kannst du sinnvolle Ergebnisse abfragen (?) alles an der Kante oder nicht.
      Auf Seite 11 -> "ELEPROXS" sollte Auskunft geben, ob das Einmessen erfolgreich war ...
      Kommt die positive Antwort Beispielsweise auch erst nach 8 Sekunden dann?

      Ich denke (hoffe), dass die Einstellungen/ Parameter f. die Tasten selbst (auch nach Reset) erhalten bleiben.

      Gruß
      port
    • Schon mal ein Vorab-Ergebnis: Ich habe "auf Null" zurückgesetzt und die Schaltung nochmals auf dem Steckbrett aufgebaut. Da muss ich nicht immer das Gehäuse aufschrauben, wenn ich den ATMega flashen möchte. Dann habe ich das modifizierte Programm von Mandarin15 draufgespielt. Modifiziert wurden: LCD-Ausgabe statt RS232 (da habe ich im Moment keine Möglichkeit) und als Controller den ATMega8. Außerdem gebe ich nicht nur den Bitstring der beiden eingelesenen Register aus, sondern über einen select auch noch die gedrückte Taste. Ergebnis: auch da werden die Tasten erst nach mehreren Sekunden angenommen. Mitgezählt sind es da um die 5-6 Sekunden. Also, nach dem Einschalten erscheint ein kurzer Text - damit ich weiß, ob das Programm angelaufen ist -, dann kann man 5-6 Sekunden immer wieder auf eine Taste drücken, ohne dass etwas passiert und danach kommt die Ausgabe der Tastenwerte in binärer Form, darunter noch der Wert der gedrückten Taste. Da dabei auch noch eine LED angesteuert wird, sobald ein Interrupt vom MPR121 beim ATMega ankommt weiß ich, dass auch mit der ursprünglichen Source der gleiche Effekt auftaucht.
      Einen 328er habe ich da. Ich versuche, eine serielle Verbindung zum PC herzustellen (irgendwo müßte ich noch so einen FDTI-Dingens haben) . Dann könnte ich die originale Source flashen und nochmals testen. Ich denke, dass dann der gleiche Effekt auftreten wird. Schau' mer mal!

      Hier noch die modifizierte Source:

      BASCOM-Quellcode

      1. '-------------------------------------------------------------------------------
      2. '
      3. 'Touch Sensor
      4. 'MPR121 (freescale) A C H T U N G ! VCC=3,3V >>>> Pegelwandler verwenden!
      5. '.............................................oder 3V3 µC-Board
      6. 'Arduino NANO / UNO ........o.ä.
      7. '
      8. 'Nov.2018 by Mandarin15
      9. '
      10. 'Demo mit Minimal-Konfiguration
      11. '
      12. '-------------------------------------------------------------------------------
      13. $regfile = "m8def.dat"
      14. $crystal = 8000000
      15. $hwstack = 40
      16. $swstack = 32
      17. $framesize = 4
      18. $PROG &HFF,&HC4,&HD9,&H00'
      19. $lib "YwRobot_Lcd_i2c.lib"
      20. Config Portb.5 = Output
      21. Led Alias Portb.5
      22. config Lcd=20 * 4
      23. config I2cdelay= 1
      24. config Scl=Portc.5
      25. config Sda=Portc.4
      26. const Pcf8574_lcd=78
      27. Const Pcf_d4 = 4
      28. Const Pcf_d5 = 5
      29. Const Pcf_d6 = 6
      30. Const Pcf_d7 = 7
      31. Const Pcf_rs = 0
      32. Const Pcf_rw = 1
      33. Const Pcf_e2 = 3
      34. Const Pcf_e1 = 2
      35. dim _lcd_e As Byte
      36. dim Lcd_backlight As Byte
      37. '________________________________________________________________________________Register lt. Datenblatt / AN3944
      38. Mhd_rising Alias &H2B
      39. Nhd_amount_rising Alias &H2C
      40. Ncl_rising Alias &H2D
      41. Fdl_rising Alias &H2E
      42. Mhd_falling Alias &H2F
      43. Nhd_amount_falling Alias &H30
      44. Ncl_falling Alias &H31
      45. Fdl_falling Alias &H32
      46. Ele0_touch_threshold Alias &H41
      47. Ele0_release_threshold Alias &H42
      48. Ele1_touch_threshold Alias &H43
      49. Ele1_release_threshold Alias &H44
      50. Ele2_touch_threshold Alias &H45
      51. Ele2_release_threshold Alias &H46
      52. Ele3_touch_threshold Alias &H47
      53. Ele3_release_threshold Alias &H48
      54. Ele4_touch_threshold Alias &H49
      55. Ele4_release_threshold Alias &H4A
      56. Ele5_touch_threshold Alias &H4B
      57. Ele5_release_threshold Alias &H4C
      58. Ele6_touch_threshold Alias &H4D
      59. Ele6_release_threshold Alias &H4E
      60. Ele7_touch_threshold Alias &H4F
      61. Ele7_release_threshold Alias &H50
      62. Ele8_touch_threshold Alias &H51
      63. Ele8_release_threshold Alias &H52
      64. Ele9_touch_threshold Alias &H53
      65. Ele9_release_threshold Alias &H54
      66. Ele10_touch_threshold Alias &H55
      67. Ele10_release_threshold Alias &H56
      68. Ele11_touch_threshold Alias &H57
      69. Ele11_release_threshold Alias &H58
      70. Filter_cfg Alias &H5D
      71. Electrode_cfg Alias &H5E
      72. Gpio_ctrl_reg_0 Alias &H73 'GPIO auf meinem Board nicht verfügbar
      73. Gpio_ctrl_reg_1 Alias &H74
      74. Gpio_data_reg Alias &H75
      75. Gpio_dir_ctrl_reg Alias &H76
      76. Gpio_enable_reg Alias &H77
      77. Gpio_data_set_reg Alias &H78
      78. Gpio_data_clear_reg Alias &H79
      79. Gpio_data_toggle_reg Alias &H7A
      80. Auto_cfg_control_0 Alias &H7B
      81. Auto_cfg_usl Alias &H7D
      82. Auto_cfg_lsl Alias &H7E
      83. Auto_cfg_target_level Alias &H7F
      84. Touch_threshold Alias &H0F
      85. Release_threshold Alias &H0A
      86. Mpr121_read_adr Alias &HB5
      87. Mpr121_write_adr Alias &HB4
      88. '_______________________________________________________________________________
      89. Dim Touch As Boolean 'Neue Daten von MPR121
      90. Dim Touchstatus As Word
      91. Dim Touchstatus_l As Byte At Touchstatus Overlay
      92. Dim Touchstatus_h As Byte At Touchstatus + 1 Overlay
      93. dim i as byte
      94. Config Pind.2 = Input 'IRQ! von MPR121 (Active Low Open-drain Interrupt Output)
      95. Portd.2 = 1 'Pullup
      96. Config Int0 = Falling 'PIND.2
      97. Enable Int0
      98. On Int0 Int0_irq
      99. $lib "i2c_TWI.lib"
      100. Config Scl = Portc.5 'Ports fuer IIC-Bus
      101. Config Sda = Portc.4
      102. Config Twi = 400000
      103. Declare Sub Mpr121write(byval Reg_address As Byte , Byval Daten As Byte)
      104. Declare Function Mpr121read(byval Read_register As Byte ) As Byte
      105. '-------------------------------------------------------------------------------
      106. I2cinit
      107. _lcd_e = 128
      108. Lcd_backlight = 1
      109. 'waitms 300
      110. locate 1,1
      111. lcd "START MPR121 Demo"
      112. Gosub Mpr121config
      113. Enable Interrupts
      114. '###############################################################################
      115. '###############################################################################
      116. Do
      117. If Touch = 1 Then
      118. locate 2,1
      119. lcd Bin(touchstatus)
      120. Touch = 0
      121. Led = 1
      122. select case touchstatus
      123. case 128:i=0
      124. case 1024:i=1
      125. case 64:i=2
      126. case 4:i=3
      127. case 512:i=4
      128. case 32:i=5
      129. case 2:i=6
      130. case 256:i=7
      131. case 16:i=8
      132. case 1:i=9
      133. end select
      134. locate 3,1
      135. lcd " "
      136. locate 3,1
      137. lcd i
      138. End If
      139. Loop
      140. '###############################################################################
      141. '###############################################################################
      142. '_______________________________________________________________________________
      143. Int0_irq:
      144. 'MPR121 Irq
      145. Touchstatus_l = Mpr121read(&H00)
      146. Touchstatus_h = Mpr121read(&H01)
      147. Touch = 1 'neue Daten
      148. Led = 0
      149. Return
      150. '_______________________________________________________________________________
      151. Mpr121config:
      152. 'Section A
      153. 'This group of setting controls the filtering of the system when the data is greater than the baseline
      154. Call Mpr121write(mhd_rising , &H01)
      155. Call Mpr121write(nhd_amount_rising , &H01)
      156. Call Mpr121write(ncl_rising , &H00)
      157. Call Mpr121write(fdl_rising , &H00)
      158. 'Section B
      159. 'This group of setting controls the filtering of the system, when the data is less than the baseline
      160. Call Mpr121write(mhd_falling , &H01)
      161. Call Mpr121write(nhd_amount_falling , &H01)
      162. Call Mpr121write(ncl_falling , &HFF)
      163. Call Mpr121write(fdl_falling , &H02)
      164. 'Section C
      165. 'The touch threshold registers set the minimum delta from the baseline when a touch is detected
      166. Call Mpr121write(ele0_touch_threshold , Touch_threshold)
      167. Call Mpr121write(ele0_release_threshold , Release_threshold)
      168. Call Mpr121write(ele1_touch_threshold , Touch_threshold)
      169. Call Mpr121write(ele1_release_threshold , Release_threshold)
      170. Call Mpr121write(ele2_touch_threshold , Touch_threshold)
      171. Call Mpr121write(ele2_release_threshold , Release_threshold)
      172. Call Mpr121write(ele3_touch_threshold , Touch_threshold)
      173. Call Mpr121write(ele3_release_threshold , Release_threshold)
      174. Call Mpr121write(ele4_touch_threshold , Touch_threshold)
      175. Call Mpr121write(ele4_release_threshold , Release_threshold)
      176. Call Mpr121write(ele5_touch_threshold , Touch_threshold)
      177. Call Mpr121write(ele5_release_threshold , Release_threshold)
      178. Call Mpr121write(ele6_touch_threshold , Touch_threshold)
      179. Call Mpr121write(ele6_release_threshold , Release_threshold)
      180. Call Mpr121write(ele7_touch_threshold , Touch_threshold)
      181. Call Mpr121write(ele7_release_threshold , Release_threshold)
      182. Call Mpr121write(ele8_touch_threshold , Touch_threshold)
      183. Call Mpr121write(ele8_release_threshold , Release_threshold)
      184. Call Mpr121write(ele9_touch_threshold , Touch_threshold)
      185. Call Mpr121write(ele9_release_threshold , Release_threshold)
      186. Call Mpr121write(ele10_touch_threshold , Touch_threshold)
      187. Call Mpr121write(ele10_release_threshold , Release_threshold)
      188. Call Mpr121write(ele11_touch_threshold , Touch_threshold)
      189. Call Mpr121write(ele11_release_threshold , Release_threshold)
      190. 'Section D
      191. 'There are three settings embedded in this register so it is only necessary to pay attention to one
      192. Call Mpr121write(filter_cfg , &H04)
      193. 'Section E
      194. 'Electrode Configuration
      195. Call Mpr121write(electrode_cfg , &H0C) 'Enable 12 Electrodes
      196. 'Section F
      197. 'Enable Auto Config and auto Reconfig
      198. 'call mpr121Write(Auto_cfg_control_0, &H0B)
      199. 'call Mpr121write(Auto_cfg_usl , &H9C)
      200. 'call Mpr121write(Auto_cfg_lsl , &H65)
      201. 'call Mpr121write(Auto_cfg_target_level , &H8C)
      202. Return
      203. '_______________________________________________________________________________
      204. Sub Mpr121write(byval Reg_address As Byte , Byval Daten As Byte)
      205. I2cstart
      206. I2cwbyte Mpr121_write_adr 'write 0xB4
      207. I2cwbyte Reg_address 'write register reg_Address
      208. I2cwbyte Daten
      209. I2cstop
      210. End Sub
      211. '_______________________________________________________________________________
      212. Function Mpr121read(byval Read_register As Byte ) As Byte
      213. Local Read_data As Byte
      214. I2cstart
      215. I2cwbyte Mpr121_write_adr
      216. I2cwbyte Read_register
      217. I2crepstart
      218. I2cwbyte Mpr121_read_adr
      219. I2crbyte Read_data , Nack
      220. I2cstop
      221. Mpr121read = Read_data
      222. End Function
      223. '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      224. End
      Alles anzeigen
    • Hallo Jogiavr,

      ich denke den groessten Teil musst du (zur Fehlersuche ) selbst aus dem MPR121-Baustein quetschen.
      Einfach mal die Automatik machen lassen ...

      Call Conf1(&H7b , &H0B)
      Call Conf1(&H7d , &H9C)
      Call Conf1(&H7e , &H65)
      Call Conf1(&H7f , &H8C)
      Was passiert dann?

      Was wurde in die Register geschrieben nach dem "Einmessen" (exemplarisch f. eine Taste)?
      Für eine Taste sind es schon einige Register ... (Datenblatt Seite 5 u.f.)

      Was bleibt davon erhalten nach dem Neustart ("ohne Auto" und ohne Mpr121config)?
      Weichen die Werte von deinen urspruenglich "aufgezwungenen Werten" enorm ab?

      Ist beim zweiten Start ueberhaupt eine neue Beschreibung der vielen Register notwendig - oder gar schaedlich.
      Moeglicherweise kommt der Baustein in deiner Konfiguration nicht damit zurecht und macht eine neue Kalibrierung?

      Schau, das einzige was du ausliest sind bisher die beiden Bytes für die gedrueckten Tasten.
      Hier ist viel Potential zum nachschauen.
      Das Auslesen der anderen Register geht ja im Prinzip ja genauso.

      '------------
      was_steht_im_register_h41 = Mpr121read(&H41)
      Bit_02_von_h41 = was_steht _im_register_h41.2
      '-----------

      Gruß
      port
    • Hallo Jogiavr,

      neuer Tag - neue Idee (google). trinkende-smileys-210

      Hier hatte jemand das gleiche Problem ... 5- 8 sec

      community.nxp.com/t5/Sensors/M…libration-time/m-p/286010

      C und English -> aber wohl Pseudocode:

      - Neustart
      - Software reset (0x80,0x63)
      - Stop modus (auch wohl vorsichtshalber) (0x5E,0x00)

      - andere Werte (zur Probe)
      - run Modus
      - Auto Calibration

      '....................
      Dramatische Verkürzung des Vorgangs (?)

      Gruß
      port
    • Hallo Port! Viiiiiielen Dank! Du hast es gelöst.
      Der Wert für die Elektroden darf nicht h0C sein, sondern hCC! Ist mir ein Rätsel, weil ja h0C dezimal 12 wäre, aber egal. Sofort nach dem Einschalten kann ich loslegen.
      Ich freue mich! Die Registerfüllung für das Auto-Config habe ich drin gelassen.
      Das gilt übrigens auch für die Source von Mandarin15. Auch dort läuft es super mit hCC.

      Für alle die es interessiert - hier die bereinigte und von der Bedienung her verbesserte Version

      BASCOM-Quellcode

      1. '(
      2. -------------------------------------------------
      3. Konverter für Zahlensysteme
      4. dez, hex, bin
      5. JM 5/2023
      6. V.0.3
      7. 2 x Touchpad MPR121 (I2C)
      8. LCD (I2C)
      9. --------------------------------------------------
      10. PC4 = SDA
      11. PC5 = SCL
      12. PD2 = INT0
      13. PD3 = INT1
      14. ---------- Konfiguration -------------------------
      15. ')
      16. $Regfile="m8def.dat"
      17. $Crystal=8000000
      18. $hwstack=40
      19. $swstack=30
      20. $framesize=40
      21. $PROG &HFF,&HC4,&HD9,&H00'
      22. $lib "YwRobot_Lcd_i2c.lib"
      23. config Lcd=20 * 4
      24. config I2cdelay= 1
      25. config Scl=Portc.5
      26. config Sda=Portc.4
      27. Config Pind.2 = Input
      28. Portd.2 = 1
      29. Config Int0 = Falling
      30. Enable Int0
      31. On Int0 Int0_irq
      32. Config Pind.3 = Input
      33. Portd.3 = 1
      34. Config Int1 = Falling
      35. Enable Int1
      36. On Int1 Int1_irq
      37. const Pcf8574_lcd=78
      38. Const Pcf_d4 = 4
      39. Const Pcf_d5 = 5
      40. Const Pcf_d6 = 6
      41. Const Pcf_d7 = 7
      42. Const Pcf_rs = 0
      43. Const Pcf_rw = 1
      44. Const Pcf_e2 = 3
      45. Const Pcf_e1 = 2
      46. const mprrd1=&HB5
      47. const mprwr1=&HB4
      48. const mprrd2=&HB7
      49. const mprwr2=&HB6
      50. i2cinit
      51. '--------- Variable ------------------------------
      52. 'dim _lcd_e As Byte
      53. dim Lcd_backlight As Byte
      54. dim key1 as word
      55. dim key1l as byte at key1 overlay
      56. dim key1h as byte at key1 + 1 overlay
      57. dim key2 as word
      58. dim key2l as byte at key2 overlay
      59. dim key2h as byte at key2 + 1 overlay
      60. dim mpr_adr as byte
      61. dim eingabe as string *1
      62. dim ausgabe as string *16
      63. dim wert as word
      64. dim auswahl as string*1
      65. dim pressed1 as byte
      66. dim pressed2 as byte
      67. dim reg as byte
      68. dim dat as byte
      69. declare sub conf1 (byval reg as byte,byval dat as byte)
      70. declare sub write_value (byval eingabe as string)
      71. declare sub setauswahl (byval eingabe as string)
      72. '--------- Hauptprogramm -------------------------
      73. '_lcd_e = 128
      74. Lcd_backlight = 1
      75. cls
      76. mpr_adr=mprwr1
      77. gosub setmpr
      78. mpr_adr=mprwr2
      79. gosub setmpr
      80. pressed1=0
      81. pressed2=0
      82. auswahl=""
      83. enable interrupts
      84. cursor on
      85. Do
      86. if pressed1=1 and key1<>0 then
      87. select case key1
      88. case 128:call write_value ("0")
      89. case 1024:call write_value ("1")
      90. case 64:call write_value ("2")
      91. case 4:call write_value ("3")
      92. case 512:call write_value ("4")
      93. case 32:call write_value ("5")
      94. case 2:call write_value ("6")
      95. case 256:call write_value ("7")
      96. case 16:call write_value ("8")
      97. case 1:call write_value ("9")
      98. end select
      99. pressed1=0
      100. end if
      101. if pressed2=1 and key2<>0 then
      102. select case key2
      103. case 128:gosub padcls
      104. case 1024:call setauswahl ("d")
      105. case 64:call setauswahl ("h")
      106. case 4:call setauswahl ("b")
      107. case 512:call write_value ("D")
      108. case 32:call write_value ("E")
      109. case 2:call write_value ("F")
      110. case 256:call write_value ("A")
      111. case 16:call write_value ("B")
      112. case 1:call write_value ("C")
      113. end select
      114. pressed2=0
      115. end if
      116. Loop
      117. '--------- Unterprogramme ------------------------
      118. sub conf1 (byval reg as byte,byval dat as byte)
      119. i2cstart
      120. i2cwbyte mpr_adr
      121. i2cwbyte reg
      122. i2cwbyte dat
      123. i2cstop
      124. end sub
      125. '---------------------------------------------------
      126. setmpr:
      127. call conf1 (&h2b,&h01)
      128. call conf1 (&h2c,&h01)
      129. call conf1 (&h2d,&h00)
      130. call conf1 (&h2e,&h00)
      131. call conf1 (&h2f,&h01)
      132. call conf1 (&h30,&h01)
      133. call conf1 (&h31,&hff)
      134. call conf1 (&h32,&h02)
      135. call conf1 (&h41,&h0f)
      136. call conf1 (&h42,&h0a)
      137. call conf1 (&h43,&h0f)
      138. call conf1 (&h44,&h0a)
      139. call conf1 (&h45,&h0f)
      140. call conf1 (&h46,&h0a)
      141. call conf1 (&h47,&h0f)
      142. call conf1 (&h48,&h0a)
      143. call conf1 (&h49,&h0f)
      144. call conf1 (&h4a,&h0a)
      145. call conf1 (&h4b,&h0f)
      146. call conf1 (&h4c,&h0a)
      147. call conf1 (&h4d,&h0f)
      148. call conf1 (&h4e,&h0a)
      149. call conf1 (&h4f,&h0f)
      150. call conf1 (&h50,&h0a)
      151. call conf1 (&h51,&h0f)
      152. call conf1 (&h52,&h0a)
      153. call conf1 (&h53,&h0f)
      154. call conf1 (&h54,&h0a)
      155. call conf1 (&h55,&h0f)
      156. call conf1 (&h56,&h0a)
      157. call conf1 (&h57,&h0f)
      158. call conf1 (&h58,&h0a)
      159. call conf1 (&h5d,&h04)
      160. Call Conf1 (&H7b,&H0B)
      161. Call Conf1 (&H7d,&H9C)
      162. Call Conf1 (&H7e,&H65)
      163. Call Conf1 (&H7f,&H8C)
      164. call conf1 (&h5e,&hCC)
      165. return
      166. '---------------------------------------------------
      167. padcls:
      168. ausgabe=""
      169. eingabe=""
      170. 'auswahl=""
      171. cls
      172. if auswahl>"" then gosub lcdauswahl
      173. return
      174. '---------------------------------------------------
      175. lcdauswahl:
      176. locate 1,18
      177. select case auswahl
      178. case "d":lcd "dez"
      179. case "h":lcd "hex"
      180. case "b":lcd "bin"
      181. end select
      182. locate 1,1
      183. return
      184. '---------------------------------------------------
      185. sub setauswahl (byval eingabe)
      186. 'if auswahl>"" then exit sub
      187. select case eingabe
      188. case "d":auswahl="d"
      189. case "h":auswahl="h"
      190. case "b":auswahl="b"
      191. end select
      192. cls
      193. gosub lcdauswahl
      194. eingabe=""
      195. ausgabe=""
      196. end sub
      197. '---------------------------------------------------
      198. sub write_value (byval eingabe)
      199. if auswahl="" then gosub padcls
      200. if auswahl="" then exit sub
      201. if auswahl="d" and len(ausgabe)=5 then exit sub
      202. if auswahl="h" and len(ausgabe)=4 then exit sub
      203. if auswahl="b" and len(ausgabe)=16 then exit sub
      204. if auswahl="b" and eingabe<>"0" and eingabe<>"1" then exit sub
      205. if auswahl="d" and eingabe>"9" then exit sub
      206. dim binwert as string*17
      207. ausgabe=ausgabe+eingabe
      208. if auswahl="d" then wert=val(ausgabe)
      209. if auswahl="h" then wert=hexval(ausgabe)
      210. if auswahl="b" then wert=binval(ausgabe)
      211. locate 1,1
      212. lcd ausgabe
      213. locate 2,1
      214. binwert=bin (wert)
      215. insertchar binwert,9," "
      216. lcd "b: ";binwert
      217. locate 3,1
      218. lcd "d: ";wert
      219. locate 4,1
      220. lcd "$: ";hex (wert)
      221. end sub
      222. '---------------------------------------------------
      223. end
      224. Int0_irq:
      225. 'MPR121 Irq
      226. I2cstart
      227. I2cwbyte Mprwr1
      228. I2cwbyte &h00
      229. I2crepstart
      230. I2cwbyte Mprrd1
      231. I2crbyte key1l,ack
      232. i2crbyte key1h,nack
      233. I2cstop
      234. pressed1 = 1
      235. return
      236. '---------------------------------------------------
      237. Int1_irq:
      238. 'MPR121 Irq
      239. I2cstart
      240. I2cwbyte Mprwr2
      241. I2cwbyte &h00
      242. I2crepstart
      243. I2cwbyte Mprrd2
      244. I2crbyte key2l,ack
      245. i2crbyte key2h,nack
      246. I2cstop
      247. pressed2 = 1
      248. Return
      249. '---------------------------------------------------
      Alles anzeigen
    • jogiavr schrieb:

      sondern hCC! Ist mir ein Rätsel,
      Die Beschreibung des Registers $5E steht im Datenblatt hinter $72 a_67_e210de67
      Die oberen beiden Bit bestimmen die Kalibrierung. So wie ich das deute übernimmt er in Default (beide 0 ) die Werte aus Register $1E-$2A. Da die keine Werte bekommen sind die 0 (default). So braucht er die 8 Sekunden sich ein zu pegeln. Sind beide high übernimmt er den ersten Wert den die Elektroden liefern und hat dann schnell den passenden Wert. Schreibt er den in die Register ($1E-2F) ? Die wären nützlich einen bevorstehenden Ausfall einer oder mehrer Elektroden zu erkennen.
      Schade das Mandarin nicht online ist. Es wäre interessant ob bei ihm die Wartezeit unauffällig klein war.

      PS @port a_57_04ef5ee8 Wie bist Du auf das $CC gekommen?

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Pluto25 ()