I2C communication PCF8574AP

HomeForumsMonoBrick EV3 FirmwareI2C communication PCF8574AP

This topic contains 21 replies, has 5 voices, and was last updated by Author Image Anders Søborg 4 years, 10 months ago.

Viewing 7 posts - 16 through 22 (of 22 total)
  • Author
    Posts
  • #4884
    Author Image
    Tcm0
    Participant

    Are you sure that the PCF8574AP is no 9V sensor? In that case you would have to use another mode.

    #4885
    Author Image
    Bartłomiej Drozd
    Participant

    yes, PCF need from 2.5V to 6V, so i have correct mode. I really don’t know, what i should do… Maybe is there any option, where i will be able to construct my own byte array to send? Like in NXC?

    #4887
    Author Image
    Helmut Wunder
    Participant

    honestly, I think only one of the Mono devs can help. Or try Java instead…?

    I also once wanted to start with Mono for an i2c device ( a Microinfinity inertial Gyro) but unfortunately got no help here in this forum so I had to abandon using Mono so far.

    #4888
    Author Image
    Bartłomiej Drozd
    Participant

    i will try with LejOS, but i don’t like Java… And still waiting for help with C# ;)

    #4889
    Author Image
    Bartłomiej Drozd
    Participant

    ok, i just tested it with LejOS and now i know, how to use it ;) i must write to register 0×16 byte array ;) and here is my test code

    public static void Main (string[] args)
    		{
    			EventWaitHandle stopped = new ManualResetEvent (false);
    			ButtonEvents btn = new ButtonEvents ();
    			byte address = 0x70;
    			byte[] data1 = new byte[1] { 0x05 };
    			byte[] data0 = new byte[1] { 0x0A };
    			LcdConsole.WriteLine ("hello world!");
    			pcf pcf = new pcf (SensorPort.In1, address);
    			btn.EscapePressed += () => {
    				LcdConsole.WriteLine("stopped");
    				stopped.Set ();
    			};
    			btn.LeftPressed += () => {
    				pcf.WriteReg(0x16, data1);
    				LcdConsole.WriteLine("write data1");
    			};
    			btn.RightPressed += () => {
    				pcf.WriteReg(0x16, data0);
    				LcdConsole.WriteLine("write data0");
    			};
    			btn.EnterPressed += () => {
    				LcdConsole.WriteLine(BitConverter.ToString(pcf.ReadReg(16, 1)));
    			};
    			stopped.WaitOne ();
    		}

    thanks for help ;)

    #4891
    Author Image
    Anders Søborg
    Key Master

    Hi there

    Sorry I wasn’t able to help along the way – for some reason I did not get an email on updates in this thread. Anyway great work this might be usefull for others. Consider creating a class for this sensor that we can use in the library.

    /Anders

    #4926
    Author Image
    Anders Søborg
    Key Master

    Hi again

    Could you please share the whole class so it can be a part of the monobrick firmware library…

    /Anders

Viewing 7 posts - 16 through 22 (of 22 total)

You must be logged in to reply to this topic.

Posted in

Make a donation