New HBridge CAL Component

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

New HBridge CAL Component

Postby Benj » Fri Aug 10, 2018 5:25 pm

Hello,

I've just dropped a H-Bridge component into the Flowcode 8 update system.

https://www.matrixtsl.com/wiki/index.ph ... ic_Updates

Current I've only added support to the 16F1937 family and the 16F18877 family but these two are very different so hopefully most other 8-bit PIC devices should mostly fall into one or the other type.

More devices to come in the near future. Any devices with the half/full H-Bridge PWM feature that you want me to support then please let me know and I'll try and make it a priority.

There will also likely be a component with a GUI to sit on top of the CAL component similar to how the PWM component sits on the PWM CAL.

Here are some simple examples if anyone wants to have a go.

HBridgeTest_1937.fcfx
(9.99 KiB) Downloaded 74 times

HBridgeTest_18877.fcfx
(10.78 KiB) Downloaded 59 times


Enjoy :D
These users thanked the author Benj for the post (total 5):
QMESAR (Fri Aug 10, 2018 5:56 pm) • jgu1 (Fri Aug 10, 2018 6:57 pm) • petesmart (Fri Aug 10, 2018 10:08 pm) • medelec35 (Fri Aug 10, 2018 10:10 pm) • celebriums (Sun Aug 12, 2018 4:55 pm)
Rating: 26.32%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 572 times
Contact:

Re: New HBridge CAL Component

Postby QMESAR » Fri Aug 10, 2018 5:54 pm

Hi Ben this is great thank you so much :D :D :D

Reading your post above I would like to take advantage and ask for the 16F15xx devices they are similar to the 18877 I use them in lightning and some small motor drives
:D :D :D

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: New HBridge CAL Component

Postby medelec35 » Fri Aug 10, 2018 10:19 pm

Hi Ben,
Thanks for the Hbridge component.
What I would like to see in properties are pin connections.
Half bridge being two and full bridge being 4.
I would also like to see a dead band added if possible please?
These users thanked the author medelec35 for the post:
petesmart (Fri Aug 10, 2018 10:30 pm)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: New HBridge CAL Component

Postby Benj » Fri Aug 10, 2018 11:39 pm

Thanks for the fast feedback :D

Hi Peter,

the 16F15xx devices


I'll look into these for you, thanks.

Hi Martin,

What I would like to see in properties are pin connections.
Half bridge being two and full bridge being 4.
I would also like to see a dead band added if possible please?


Yep I think it should do all that now. The dead band should only be shown on devices that have it available. The 16F1937 family I believe does not but the 16F18877 family does. Remap pins and alt pins are also supported.

Full Bridge
Settings.jpg
Settings.jpg (68.97 KiB) Viewed 2971 times


Half Bridge
Settings2.jpg
Settings2.jpg (61.87 KiB) Viewed 2971 times
These users thanked the author Benj for the post (total 2):
medelec35 (Sat Aug 11, 2018 12:33 am) • QMESAR (Sat Aug 11, 2018 7:14 am)
Rating: 10.53%
 

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: New HBridge CAL Component

Postby Benj » Mon Aug 13, 2018 10:35 am

I've now added the H-bridge half mode to PIC 16(L)F150x and 12(L)F150x devices and pushed the change to the update system. There is no full mode available on these devices.

Strangely the 12F device is the only one in the family that has alt pins for the H-Bridge output.

Are these the devices you meant Peter?
These users thanked the author Benj for the post:
QMESAR (Mon Aug 13, 2018 10:53 am)
Rating: 5.26%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 572 times
Contact:

Re: New HBridge CAL Component

Postby QMESAR » Mon Aug 13, 2018 10:53 am

Ben thank you very much the F150x devices they are small and very cheap use then quite a bit
Appreciate what you did Ben

PS I just updated and that is the once Ben specially for me the 1508 and 1509 Great stuff
These users thanked the author QMESAR for the post:
Benj (Mon Aug 13, 2018 11:34 am)
Rating: 5.26%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: New HBridge CAL Component

Postby medelec35 » Mon Aug 13, 2018 1:39 pm

Hi Ben,
Tried HBridge Cal component today and got the following error with 16F18877:

Code: Select all

Launching the compiler...
C:\Program Files (x86)\Flowcode\Compilers\pic\batch\pic_xc8_comp.bat  16F18877 "M:\Flowcode Testing\" "HBridgeTest_18877"

M:\Flowcode Testing>C:\PROGRA~2\Flowcode\COMPIL~1\pic\batch\..\bin\xc8.exe --chip=16F18877  "HBridgeTest_18877.c" --MSGDISABLE=359,1273,1388 --FLOAT=32 --DOUBLE=32
Microchip MPLAB XC8 C Compiler (PRO Mode) V1.45
Build date: Nov 15 2017
Part Support Version: 1.45
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration

C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_HBRIDGE.c: FC_CAL_HBRIDGE_Enable_1()
   231:   MX_HBRIDGE_A_RPOR_X = MX_HBRIDGE_A_RPOC_X;
   ^ (192) undefined identifier "MX_HBRIDGE_A_RPOR_X"
                         ^ (192) undefined identifier "MX_HBRIDGE_A_RPOC_X"
   232:   MX_HBRIDGE_B_RPOR_X = MX_HBRIDGE_B_RPOC_X;
   ^ (192) undefined identifier "MX_HBRIDGE_B_RPOR_X"
                         ^ (192) undefined identifier "MX_HBRIDGE_B_RPOC_X"
   233:   MX_HBRIDGE_C_RPOR_X = MX_HBRIDGE_C_RPOC_X;
   ^ (192) undefined identifier "MX_HBRIDGE_C_RPOR_X"
                         ^ (192) undefined identifier "MX_HBRIDGE_C_RPOC_X"
   234:   MX_HBRIDGE_D_RPOR_X = MX_HBRIDGE_D_RPOC_X;
   ^ (192) undefined identifier "MX_HBRIDGE_D_RPOR_X"
                         ^ (192) undefined identifier "MX_HBRIDGE_D_RPOC_X"
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]

C:\Program Files (x86)\Flowcode\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1



FINISHED


With 16F1937:

Code: Select all

Launching the compiler...
C:\Program Files (x86)\Flowcode\Compilers\pic\batch\pic_xc8_comp.bat  16F1937 "M:\Flowcode Testing\" "HBridgeTest_1937"

M:\Flowcode Testing>C:\PROGRA~2\Flowcode\COMPIL~1\pic\batch\..\bin\xc8.exe --chip=16F1937  "HBridgeTest_1937.c" --MSGDISABLE=359,1273,1388 --FLOAT=32 --DOUBLE=32
Microchip MPLAB XC8 C Compiler (PRO Mode) V1.45
Build date: Nov 15 2017
Part Support Version: 1.45
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration

C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_HBRIDGE.c: FC_CAL_HBRIDGE_Enable_1()
    77:   CCPR1l = 0;
   ^ (192) undefined identifier "CCPR1l"
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]

C:\Program Files (x86)\Flowcode\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1

I have checked for updates prior to compiling.

Edit. Corrected Cal for 16F1937.
Compiles OK but no output from any HBridge Pins.

Benj wrote:The dead band should only be shown on devices that have it available. The 16F1937 family I believe does not
Deadband control.png
Deadband control.png (41.29 KiB) Viewed 2886 times
Last edited by medelec35 on Mon Aug 13, 2018 2:29 pm, edited 1 time in total.
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: New HBridge CAL Component

Postby Benj » Mon Aug 13, 2018 4:08 pm

Hi Martin,

Tried HBridge Cal component today and got the following error with 16F1887


Looks like the HBridge remap definitions are not in place. Have you assigned the remap pins via the comp properties?

With 16F1937:


This is very odd, I had that problem myself and fixed it well before I uploaded the code. Hmm.

Both device above have been very well tested on H/W so it's odd that it's not working for you.

The dead band should only be shown on devices that have it available. The 16F1937 family I believe does not


That line in the datasheet could be a typo, I didn't find any registers that would allow me to set the rising and falling dead band like there are on the other devices. I'll have another look. Edit aha think I've found it now, need to think about this one!!!

I've added more device support now so and also added the HBRIDGE count to the Device Helper component. I'll get everything pushed to the update system in the next few minutes. edit: now pushed.
These users thanked the author Benj for the post:
medelec35 (Mon Aug 13, 2018 4:11 pm)
Rating: 5.26%
 

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: New HBridge CAL Component

Postby Benj » Mon Aug 13, 2018 4:31 pm

Dead-band support now added for the 16F1937 family and pushed to the update system.

It's not 100% clean as it currently appears in the component that it can be used for both half and full modes but actually it's only the half mode where it applies.
These users thanked the author Benj for the post:
medelec35 (Mon Aug 13, 2018 4:41 pm)
Rating: 5.26%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: New HBridge CAL Component

Postby medelec35 » Mon Aug 13, 2018 4:37 pm

Hi Ben,
Benj wrote:Both device above have been very well tested on H/W so it's odd that it's not working for you.

Not sure why could not get either to work, when both worked there? :?
Benj wrote:Looks like the HBridge remap definitions are not in place. Have you assigned the remap pins via the comp properties?
Left as they were on the original flowchart:
Remap pins look assigned?
Remap2.png
Remap2.png (286.18 KiB) Viewed 2865 times

Benj wrote:That line in the datasheet could be a typo

Could be, but DeadBand is also mentioned in PIC16F1934/36/37 and PIC16LF1934/36/37 Errata:
Si Errata.jpg
Si Errata.jpg (131.74 KiB) Viewed 2870 times

Edit:
Not seen Ben's last post prior to posting this post.
So did not see that Deadband is now added to 16F1937
Last edited by medelec35 on Mon Aug 13, 2018 10:39 pm, edited 1 time in total.
Reason: Added an edit
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: New HBridge CAL Component

Postby Benj » Wed Aug 15, 2018 12:20 pm

Hi Martin,

Just tested this on my home PC and yes there does seem to be a problem, I'm getting the same problems you reported and from looking at the CAL C file I can see why it's not working. Most of the code is missing!!

I'm back in the office tomorrow so hopefully I can resolve this for you then.
These users thanked the author Benj for the post:
medelec35 (Wed Aug 15, 2018 12:22 pm)
Rating: 5.26%
 

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: New HBridge CAL Component

Postby Benj » Thu Aug 16, 2018 11:42 am

We've found the cause of the problem. It only effected the CAL_PIC_HBRIDGE.c file.

The file that was being downloaded was a pre-release file and not the current release file. Hence the compiler errors you were getting.

Hopefully it should all work as expected now we have got rid of the pre-release.

The current version of the file should be version 5.

If you are not getting the latest version showing up then please navigate to this folder.

"C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC"

And delete this file.

PIC_CAL_HBridge.c

Then try doing a full update again.

Let me know how you get on.
These users thanked the author Benj for the post:
medelec35 (Thu Aug 16, 2018 11:44 am)
Rating: 5.26%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: New HBridge CAL Component

Postby medelec35 » Thu Aug 16, 2018 1:24 pm

Hi Ben.
Re 16F1937:
With attached modified flowchart
C2 duty is 100% Not expected
D5 duty is 0% Not expected
D6 duty is 0% Not expected
D7 duty is 14% this seems correct

Re 16F18877
C0 duty is 100% Not expected
B0 duty is 0% Not expected
B1 duty is 0% Not expected
B2 duty is 14% this seems correct

What is confusing is the example Flowchart supplied has pin mapping defaulted to:
A pin B0
B pin B1
C pin B2
B pin B3
However, there is an output direction>B6
Also a code Icon:

Code: Select all

TRISC = 0x00;
PORTC = TMR2;
:?
Attachments
HBridgeTest_18877 V2.fcfx
(11.23 KiB) Downloaded 24 times
HBridgeTest_1937 V2.fcfx
(10.92 KiB) Downloaded 21 times
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: New HBridge CAL Component

Postby Benj » Fri Aug 17, 2018 2:49 pm

Hi Martin,

The direction output to B6 and the count on Port C are simply part of my debugging project to make sure things were running as expected. e.g. that the loop was running and the timer was counting.

Re 16F1937:
With attached modified flowchart
C2 duty is 100% Not expected
D5 duty is 0% Not expected
D6 duty is 0% Not expected
D7 duty is 14% this seems correct

Re 16F18877
C0 duty is 100% Not expected
B0 duty is 0% Not expected
B1 duty is 0% Not expected
B2 duty is 14% this seems correct


This sounds correct to me. The component should only drive the 4 outputs in full bridge mode. One pin should be on, two should be off and the fourth pin should be PWM with varying duty.

Switching motor direction and the two pins that were off should become enabled, one on and one PWM.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: New HBridge CAL Component

Postby medelec35 » Fri Aug 17, 2018 4:44 pm

For a full bridge controlling, I thought will have both A & C in in phase and B & D in phase but the inverse of A & C?
So a typical snapshot in time:
A & C = 1, B & D = 0
Then all changes. A & C = 0, B & D = 1
Half bridge will have A=1 & B=0, then A=1 & B=1? :oops:
The full or Half bridge will then connect to FETS which in turn drive motor.

Or have I completely got it wrong?
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: New HBridge CAL Component

Postby Benj » Mon Aug 20, 2018 11:08 am

Hi Martin,

My knowledge of H-bridges is ok but not great but I think you only need 2 of the FETs to be on in a normal drive situation.

Looking at the output relationships table in the datasheet it seems to show two inactive pins, one active and one modulated which seems to be what we both are getting.

FB_Truth.jpg
FB_Truth.jpg (52.9 KiB) Viewed 2742 times


I've put together a WIKI page with the schematics from the datasheet.
https://www.matrixtsl.com/wiki/index.php?title=Component:_HBRIDGE_(CAL)_(Peripheral_CAL)

See what you think as there is likely more useful information that we can add here.

One thing that does seem lacking, when I designed the Formula AllCode H-bridge drivers I did them in a way that allowed 4 modes of operation, forwards, reverse, brake and coast. Looking at the datasheet the brake and coast modes seem to be missing!
These users thanked the author Benj for the post:
medelec35 (Mon Aug 20, 2018 12:59 pm)
Rating: 5.26%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: New HBridge CAL Component

Postby medelec35 » Mon Aug 20, 2018 1:17 pm

Hi Ben,
Thanks for the explanation.
I have misunderstood.
Now I have seen the circuit I realised I was wrong.

Is it too much to ask to ask for inverted outputs as well please?
I have remembered that people have asked for this in the past.
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: New HBridge CAL Component

Postby Benj » Mon Aug 20, 2018 4:14 pm

Hi Martin,

Is it too much to ask to ask for inverted outputs as well please?


I have provided the Polarity property which allows you to drive the pin in active high or active low modes. Does this do what you require?

For outputs A and C I would use P channel FETs combined with active low outputs.

For outputs B and D I would use N channel FETs combined with active high outputs.

Above is assuming I'm using logic level FETs, otherwise I might use a NPN transistor to drive the P Channel FETs and this way the polarity can stay active high for all outputs A-D.

Dick_Miller_UK
Posts: 12
Joined: Thu Mar 15, 2012 12:14 pm
Has thanked: 2 times
Been thanked: 4 times
Contact:

Re: New HBridge CAL Component

Postby Dick_Miller_UK » Mon Oct 07, 2019 8:02 am

Good morning,

Can you please confirm whether the HBridge component is available in Flowcode version 7, or is it only in F8?

Thanks in advance.
Dick

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: New HBridge CAL Component

Postby Benj » Mon Oct 07, 2019 1:38 pm

Hi Dick,

Sorry the H-Bridge component is only available in v8 though you could use some C code to configure the H-bridge in v7. As I recall there are not too many registers involved.

Dick_Miller_UK
Posts: 12
Joined: Thu Mar 15, 2012 12:14 pm
Has thanked: 2 times
Been thanked: 4 times
Contact:

Re: New HBridge CAL Component

Postby Dick_Miller_UK » Tue Oct 08, 2019 9:14 am

Ok, thanks Ben.

It's probably a good excuse for me to upgrade... :D

Cheers.
These users thanked the author Dick_Miller_UK for the post:
Benj (Tue Oct 08, 2019 9:48 am)
Rating: 5.26%