New HBridge CAL Component

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

Moderator: Benj

Post Reply
User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

New HBridge CAL Component

Post by Benj »

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 266 times
HBridgeTest_18877.fcfx
(10.78 KiB) Downloaded 257 times
Enjoy :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: New HBridge CAL Component

Post by QMESAR »

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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: New HBridge CAL Component

Post by medelec35 »

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?
Martin

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

Re: New HBridge CAL Component

Post by Benj »

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 7734 times
Half Bridge
Settings2.jpg
Settings2.jpg (61.87 KiB) Viewed 7734 times

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

Re: New HBridge CAL Component

Post by Benj »

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?

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: New HBridge CAL Component

Post by QMESAR »

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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: New HBridge CAL Component

Post by medelec35 »

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
(41.29 KiB) Downloaded 3816 times
Last edited by medelec35 on Mon Aug 13, 2018 2:29 pm, edited 1 time in total.
Martin

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

Re: New HBridge CAL Component

Post by Benj »

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.

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

Re: New HBridge CAL Component

Post by Benj »

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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: New HBridge CAL Component

Post by medelec35 »

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
(286.18 KiB) Downloaded 3795 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 7633 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

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

Re: New HBridge CAL Component

Post by Benj »

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.

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

Re: New HBridge CAL Component

Post by Benj »

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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: New HBridge CAL Component

Post by medelec35 »

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 148 times
HBridgeTest_1937 V2.fcfx
(10.92 KiB) Downloaded 148 times
Martin

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

Re: New HBridge CAL Component

Post by Benj »

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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: New HBridge CAL Component

Post by medelec35 »

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

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

Re: New HBridge CAL Component

Post by Benj »

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 7505 times
I've put together a WIKI page with the schematics from the datasheet.
https://www.matrixtsl.com/wiki/index.ph ... heral_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!

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: New HBridge CAL Component

Post by medelec35 »

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

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

Re: New HBridge CAL Component

Post by Benj »

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: 13
Joined: Thu Mar 15, 2012 12:14 pm
Has thanked: 2 times
Been thanked: 4 times
Contact:

Re: New HBridge CAL Component

Post by Dick_Miller_UK »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: New HBridge CAL Component

Post by Benj »

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: 13
Joined: Thu Mar 15, 2012 12:14 pm
Has thanked: 2 times
Been thanked: 4 times
Contact:

Re: New HBridge CAL Component

Post by Dick_Miller_UK »

Ok, thanks Ben.

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

Cheers.

Post Reply