MCP23017 - One I2C transaction for stepper motor control

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Zhmil1789
Posts: 10
http://meble-kuchenne.info.pl
Joined: Sun Mar 01, 2026 6:50 pm
Has thanked: 9 times

Flowcode v10 MCP23017 - One I2C transaction for stepper motor control

Post by Zhmil1789 »

Hi,
I am using Flowcode with MCP23017 I2C expander to control a stepper motor.
I have two pins on PORTA:

Pin 0 = direction
Pin 1 = step

Currently I use WritePortPin macro in a loop with delays between steps. This creates separate I2C transaction for each step.
According to MCP23017 datasheet, Byte mode (IOCON.SEQOP) allows continuous writing to the same register without sending address each time.
My question: Is it possible in Flowcode to keep I2C transaction open between WritePort/WritePortPin calls, so I can send multiple step pulses with delays inside one transaction? Or is there a way to access raw I2C bus directly while using MCP23017 component?

Thank you

BenR
Matrix Staff
Posts: 2208
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 606 times
Been thanked: 803 times

Re: MCP23017 - One I2C transaction for stepper motor control

Post by BenR »

Hello,

Both are possible yes.

The straightforward way is to look at the generated C code, specifically the MCP23017 component macros and then copy and paste this C code into your own function using the C code icon. You can then edit the C code as required.

The more customised way would be to take the MCP23017 component source from the wiki and add the functionality you need directly into the component creating your own customised version of the component.

Zhmil1789
Posts: 10
Joined: Sun Mar 01, 2026 6:50 pm
Has thanked: 9 times

Re: MCP23017 - One I2C transaction for stepper motor control

Post by Zhmil1789 »

Thank you for your reply! Could you tell me exactly what you mean by custom version? In flowcode, can I download the components myself and customize them?


With respect
Zhmil1789

BenR
Matrix Staff
Posts: 2208
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 606 times
Been thanked: 803 times

Re: MCP23017 - One I2C transaction for stepper motor control

Post by BenR »

Hello,

Yes all of the component source files are on the wiki, if you right click on the component in flowcode and goto help it should take you right to the correct page. The source for the component is usually at the bottom of the page though can sometimes be near the top.

If you take a component source and edit it then you can goto "File -> Export -> Export this project as a component" to export as a component for your version of Flowcode. Be careful though as doing library updates will overwrite your customisations. If you want to put your version into a different place so that library updates won't overwrite it then you can save wherever you like and then add this directory via "File -> Global Settings -> Locations -> Look for components in..."

Post Reply