PFC8574 IO Expander mit Robo Pro Coding

Alles rund um TX(T) und RoboPro, mit ft-Hard- und Software
Computing using original ft hard- and software
Forumsregeln
Bitte beachte die Forumsregeln!
Antworten
Benutzeravatar
fishfriend
Beiträge: 1835
Registriert: 26 Nov 2010, 11:45

PFC8574 IO Expander mit Robo Pro Coding

Beitrag von fishfriend » 27 Apr 2024, 15:44

Hallo...
Ich hab mich mal mit I2C mit Robo Pro Coding, etwas mehr beschäftigt und mit den PFC8574 IO Expander ein paar Versuche gemacht.
Hier mal ein lauffähiges Programm:
PFC8574 I2C TXT 4_0.png
PFC8574 I2C TXT 4_0.png (133.7 KiB) 361 mal betrachtet
Die einzige Variable die im Programm erstellt wurde, ist o3.
An den beiden Ausgänge P0 und P1 hängt jew. eine LED mit jew. einem 1k Ohm Widerstand nach Plus (!).
Der Taster an P2 wird nur gegen Masse geschaltet, da der EIngang einen Pullup WIderstand gegen Plus im IC hat.

Es gibt bestimmt noch elegantere Möglichkeiten es zu machen, z.B. in dem man EIngangsvariablen nimmt, wo der jew. Eingang oder Ausgang der übertragen werden soll angegeben wird. Aber das kann jeder für sich selber machen.
Wenn jemand bessere Beispiel hat her damit :-)

(Das Ziel war es, den NFC Reader PN532 ohne Bibliothek anzusteuern und nur direkt Bytes zu senden. Der PFC8543 ist nur zum testen da gewesen.)
Mit freundlichen Grüßen
Holger
ft Riesenräder PDF: ftcommunity.de/knowhow/bauanleitungen
TX-Light: Arduino und ftduino mit RoboPro

juh
Beiträge: 910
Registriert: 23 Jan 2012, 13:48

Re: PFC8574 IO Expander mit Robo Pro Coding

Beitrag von juh » 27 Apr 2024, 16:03

Hallo Holger,

weniger an dich, sondern nur zum PCF8574 eine kleine allgemeine Warnung, weil der ja häufig als Portexpander genannt wird und leicht zu bekommen ist, ich glaube von Peter gab es auch schon mal ein Gehäuse für eines der gängigen Module: Die Ein-/Ausgänge unterliegen verschiedenen Limitierungen, wodurch sie nicht gleichwertig z.B. mit den normalen Ausgängen eines Microprozessors sind, teils braucht es Zusatzbeschaltung um z.B. einen Treiber zu schalten oder Ähnliches.

vg
Jan

vleeuwen
Beiträge: 1577
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: PFC8574 IO Expander mit Robo Pro Coding

Beitrag von vleeuwen » 27 Apr 2024, 19:04

The problem with the NFC Reader PN532 is that it needs clock stretching.

That can not be test with a simple test, you need a slave that holds down the clock.

Does the TXT4.0 has implemented the I2C clock stretching protocol and what are the specifications?
The TXT had problems with it.
he TXT4.0 I2C is not documented well.

https://onlinedocs.microchip.com/pr/GUI ... 3CF0FC6966

A work around (trick) could be lowering the I2C speed from 100kHz to 50kHz.
(Or using the additional port to hold down the reading.)
software enigineer/teacher/advisor
Google translate
http://tescaweb.nl/Carel/?p=713

Benutzeravatar
fishfriend
Beiträge: 1835
Registriert: 26 Nov 2010, 11:45

Re: PFC8574 IO Expander mit Robo Pro Coding

Beitrag von fishfriend » 28 Apr 2024, 07:00

Hallo...
Noch mal zum Programm von oben. Das war die erste Version.
Inzwischen hab ich eine etwas andere, wo z.B. statt
write_byte_data(DEVICE_Adress, 0x00, 3)
nun
write_byte(DEVICE_ADDRESS, 3)
und für
read_byte_data(DEVICE_ADDRESS, 4)
read_byte(DEVICE_ADDRESS)
steht.

:-)
Ja, ich hab mir auch den Artikel durchgelesen. Die haben in der Schaltung 5V und 470 Ohm genommen. Da ich nicht weiss wieviel der TXT 4.0 liefern kann und die LEDs nicht unbedingt als Raumbeleuchtung dienen sollen, hab ich denen jew. 1k Ohm spendiert. Sie leuchten und man kann es erkennen.
Ja, der Typ hat auch Nachteile (s. Artikel).
Ich hatte den gerade da und er kann halt mit 3,3V betrieben werden.
Was bei den Moulen auch von Nachteil ist, dass die keinen VCC und GND Pin haben. Wenn man Glück hat, ist es der letzte im I2C Bus und man kann die Ausgangsbuchsen für den nächsten nehmen oder man muss bei der Adresswahl Plus und Minus abnehmen.

I am not shure.
As far as i see, the only clock stretching is needed, when the PN532 is in the sleep mode (by programm) or the (batt-) voltage ist going down.
In the wakeup sequence is then the clock streching.
So if that doesent happend, you dont need the clock streching.
I havent read (and understand) the hole manual. ;-)
Yes, i have no idear, if the TXT 4.0 has ist or not. But it is in the factory modell at a TXT 4.0 and it works. And no one knows how exatctly...

Ich hab mal spasses halber Sachen aus dem Factory gelöscht um nur im Hauptprogramm mit den NFC zu experimentieren. Ich hab z.B. die unabhängigen Treaths gelöscht, damit "nur" das Hauptprogramm läuft und "nur" die Funktionsaufrufe der NFC.
Lustigerweise kam dennoch die Felermeldung, dass auf dem I2C der BME Umweltsensor nicht gefunden wurde.
Wie und warum auch immer der gesucht wurde, ist mir (noch) ein Rätsel... ;)
Mit freundlichen Grüßen
Holger
ft Riesenräder PDF: ftcommunity.de/knowhow/bauanleitungen
TX-Light: Arduino und ftduino mit RoboPro

vleeuwen
Beiträge: 1577
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: PFC8574 IO Expander mit Robo Pro Coding

Beitrag von vleeuwen » 28 Apr 2024, 17:55

I use a PN532 in combination with an FT232H (USB to I2C+GPIO) or with a RaspberryPi 4 (hardware bug older versions), both have no clock stretching, and I have experienced that clock stretching is used during read/write operations of a chip (I2C bus 400kHz) .
On the ReaspberryPi5 the clock stretching is Ok.
Clock stretching is only used within the handling of an I2C write or read operation. See the I2C documentation/specification.
It is quite possible to make an I2C connection with a PN532, but the more extensive read/write operation for reading/writing the data blocks on a card does not work well.

But at what I2C bus speed does the TXT4.0 actually work?
With the TXT this was lower than 100kHz, measured on the bus.

The BNO055 (Smart sensor combining accelerometer, gyroscope, magnetometer and orientation) also uses clock stretching.
It seems likely to me that some form of clock stretching or workaround has been implemented on the TXT4.0, but this has not been described by fischertechnik.
I am not shure.
As far as i see, the only clock stretching is needed, when the PN532 is in the sleep mode (by programm) or the (batt-) voltage ist going down.
In the wakeup sequence is then the clock streching.
So if that doesent happend, you dont need the clock streching.
I havent read (and understand) the hole manual. ;-)
Yes, i have no idear, if the TXT 4.0 has ist or not. But it is in the factory modell at a TXT 4.0 and it works. And no one knows how exatctly.
Zuletzt geändert von vleeuwen am 28 Apr 2024, 20:08, insgesamt 1-mal geändert.
software enigineer/teacher/advisor
Google translate
http://tescaweb.nl/Carel/?p=713

vleeuwen
Beiträge: 1577
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: PFC8574 IO Expander mit Robo Pro Coding

Beitrag von vleeuwen » 28 Apr 2024, 19:25

I took a look into this data sheet
STM32MP157C MPU with Arm Dual Cortex-A7 650 MHz, Arm Cortex-M4 real-time coprocessor, 3D GPU,
This one is offering an Optional hardware clock stretching
Maybe somebody knows the exact type of the chip set in the TXT4.0.
However the questions stays: does the OS support this?
3.39 Inter-integrated circuit interface (I2C1, I2C2, I2C3, I2C4, I2C5,
I2C6)
The STM32MP157A embeds six I2C interfaces.
The I2C bus interface handles communications between the STM32MP157A and the serial I2C bus.
It controls all I2C bus-specific sequencing, protocol, arbitration and timing.
The I2C peripheral supports:
• I2C-bus specification and user manual rev. 5 compatibility:
Slave and master modes, multimaster capability
Standard-mode (Sm), with a bitrate up to 100 kbit/s
– Fast-mode (Fm), with a bitrate up to 400 kbit/s
– Fast-mode Plus (Fm+), with a bitrate up to 1 Mbit/s and 20 mA output drive I/Os

– 7-bit and 10-bit addressing mode, multiple 7-bit slave addresses
– Programmable setup and hold times
Optional clock stretching

• System management bus (SMBus) specification rev 2.0 compatibility:
– Hardware PEC (packet error checking) generation and verification with ACK
control
– Address resolution protocol (ARP) support
– SMBus alert
• Power system management protocol (PMBus™) specification rev 1.1 compatibility
• Independent clock: a choice of independent clock sources allowing the I2C
communication speed to be independent from the PCLK reprogramming.
• Wakeup from Stop mode on address match
• Programmable analog and digital noise filters
• 1-byte buffer with DMA capability
I2C4 and I2C6 can be defined (in ETZPC) as accessible by secure software onl
software enigineer/teacher/advisor
Google translate
http://tescaweb.nl/Carel/?p=713

Antworten