Page 1 of 1

i2c Not working on Raspberry pi 1B

Posted: Mon Sep 30, 2019 4:19 pm
by Abelynux
Hi everyone!

Very excited to be here! I just recently found about flowcode and, in the company I work we are very interested to adopt flowcode as our embedded IDE for test equipment development. We are specially interested on developing on the raspberry pi and arduino, so, I'm on the task to evaluate the software. I'm on an issue where I can't make the i2c work for raspberry (not yet started on arduino), I'm using a PCF8574 and I just want to blink an LED connected on one of its pins,
*I have tried several approaches, first the i2c_master, then the cal i2c and also the PCF8574 components without any success...
*I tried the i2cdetect to confirm operation of the i2c on the rpi, it detected the pcf on address 0x24, i was able to send the i2cset command and turn the led on and off (all these on the rpi terminal).
*I tried with both software and channel options (still don't understand what is the difference or intention of this mode), I also tried different speeds.

Hope someone can help!
Thanks and Best Regards!

Re: i2c Not working on Raspberry pi 1B

Posted: Tue Oct 01, 2019 9:01 am
by LeighM
Hi,
Thanks for evaluating Flowcode!

The “software” mode directly manipulates any generic GPIO pins to implement the I2C protocol.
(Except the usual I2C pins if the Raspberry Pi hardware I2C is enabled!)
Using the Flowcode I2C “software mode” will work with all the Flowcode I2C derivative components.

The I2C component “hardware” mode only works with the installed Linux driver (e.g. /dev/i2c-1)
and this is only supported by the Flowcode I2C (CAL) component. See the “Creation” menu list.

The I2C (CAL) component has additional API to work with the Raspberry Pi transaction based drivers, namely:
Transaction_Intialise (pass the device address as a parameter)
Transaction_Read (pass a buffer to receive the transaction data)
Transaction_Write (pass a buffer that contains transaction data to send)

Hope that helps,
Leigh

Re: i2c Not working on Raspberry pi 1B

Posted: Wed Oct 02, 2019 8:48 pm
by Abelynux
Hello! Thanks for your response Leigh!

I have been busy, I had a few minutes to play with the software today, I'm still struggling with the communication with i2c, now I understand the Channel option, so I tried using 2 different pair of GPIOs with the software mode, but still no luck, I did it using the 3 i2c components.

I will try to get more pictures with all the approaches I did or better the flowcode files, to begin with I attached the one with the PCF8574 component, also, we ordered a newer version of the RPi (is a 3 version but not sure what model A,B or whatever), we may wait to test with that.

Something that I'm stuck also, is when trying to fill a byte array variable, how I suppose to pass the value?, BYTE[], for the short reading I did, it seems like I have to convert to string, which sounds weird.

Best Regards!
Abel

Re: i2c Not working on Raspberry pi 1B

Posted: Thu Oct 03, 2019 10:13 am
by LeighM
Hi Abel,
Have you set the correct address for the PCF8574 ?
It is based on the wiring of the PCF8574 A0,1,2 pins, which are usually all tied low for one device, hence address 0.
Have you got pull-up resistors on the clock and data pins?
Strings and byte arrays are pretty much interchangeable in Flowcode, so if the component macro requests a string parameter then you can pass a byte array variable. Similarly you can use string variables to store a series of byte values.

Re: i2c Not working on Raspberry pi 1B

Posted: Thu Oct 03, 2019 1:46 pm
by Abelynux
Hi Leigh!

Address is set correctly, but you pointed something, initially when I was playing with the "native" i2c channel, I didn't install pull ups due it supposes it already have them, so I just missed them when I tried with the software mode, I haven't tried but I will do shortly. I will keep you posted.

Thanks a lot!

Re: i2c Not working on Raspberry pi 1B

Posted: Fri Oct 04, 2019 3:24 pm
by Abelynux
Hi Leigh!

I was able to make it work with the software mode for the PCF and i2c_master components, the pull ups did it, Thanks for pointing that!... I can't make the cal_i2c work in hardware mode yet. I will be busy for a few days, so I may not be able to continue until end of next week.

I still struggling with the byte array value assignation, this is required on the cal_i2c transaction_write parameters, I tried for example, 255,0,34,... but it throws me an error: syntax error, not sure what it is expecting. Attached a picture of the section where I need to fill the byte[] array.

Thanks so much for your help!
Abel

Re: i2c Not working on Raspberry pi 1B

Posted: Fri Oct 04, 2019 5:04 pm
by Benj
Hello,

You need to pass the byte array via avariable, so create a byte variable as normal and at the end of the variable name add the square brackets and the number of items inside the array.

e.g. myVar[3]

You can then initialise the array using a calculation icon in your program.

myVar[0] = 255
myVar[1] = 0
myVar[2] = 34

Then simply pass MyVar as the parameter.

Re: i2c Not working on Raspberry pi 1B

Posted: Sat Oct 05, 2019 11:17 am
by LeighM
And pass Length parameter as 3 in that example