Nine Bit Binary Compare

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
jbell
Flowcode V4 User
Posts: 13
Joined: Mon Jul 18, 2011 11:04 pm
Has thanked: 1 time

Nine Bit Binary Compare

Post by jbell »

All,

I’m embarking on a project that will require me to compare a binary number from an external source with a binary number entered into Flowcode. If they are the same, an output goes high. All fairly straightforward, except I need to be able to count to 1000 so I need 9 bits. My processor is a PIC 18F4520 which is, of course, 8 bits so I’ll need to “borrow” a bit from a second port. My first thought was to simply divide the ports into high-byte and low-byte and do separate comparisons. The problem is that would take more than twice as many clock cycles as a single port and speed is also an issue since the external binary number could be changing as fast as every microsecond. I would very much appreciate any thoughts from the community on how I might do this in the most efficient manner, preferably without the use of C or Assembly as I’m not terribly advanced in that level of programming.

Thanks,

Jim Bell

User avatar
DavidA
Matrix Staff
Posts: 1076
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: Nine Bit Binary Compare

Post by DavidA »

Hey jbell,

I would imagine that its not possible to do it as efficiently as you are requiring in Flowcode, you could do an 8bit and a 1bit compare in Flowcode but im not sure how the ASM would look and whether it would be more efficient than two 4bit compares. If you want real speed and efficiency i would have thought you would need to use C or ASM to accomplish what you want.

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: Nine Bit Binary Compare

Post by Benj »

Hello,

The most optimum solution would be to do two 8-bit comparisons.

so you would store your compare variables eg.

compa = 0x01
compb = 0x48

Then you would collect the data from the ports using input icons

portcompa = porta
portcompb = portb

Then mask off the single bit

portcompa = portcompa & 0x01

Then perform the comparison using a decision.

(portcompa == compa) && (portcompb == compb)

jbell
Flowcode V4 User
Posts: 13
Joined: Mon Jul 18, 2011 11:04 pm
Has thanked: 1 time

Re: Nine Bit Binary Compare

Post by jbell »

Thanks very much David and Ben for your thoughts.

I figured it would be a stretch trying to do this in Flowcode with the throughput I'm going to need. Nonetheless, I'm gonna ramp my processor up to 40MHz and give it a shot.

Worst case I'll have to drop back to a hardware solution and use a couple of 74xx688's to do the compare and just use Flowcode to wait for a "match" signal.

Regards,

Jim Bell

Post Reply